易截截图软件、单文件、免安装、纯绿色、仅160KB

Ajax提交表单 貌似只能用post

     以前提交表单的方法是submit,但是这样的话无法使用Ajax,一提交就意味着需要刷新页面。另一种方法是在url上面加上parameter来发送表单,但是这样会暴露发送的内容。但是如果用Ajax发送表单的话就能避免上面两种问题。
     但是我之前自己写的时候,总是提交的是null值,运行也没有异常。后来发现必须要变成“post”才能执行成功。下面贴出提交表单部分的Ajax代码:
createXMLHttp();
xmlHttp.open("post", "/project/action.do?method=actionMethod&"+ Math.round(Math.random() * 100), true);
xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = handleActionMethod;
xmlHttp.send("name=" + name + "&detail=" + detail);
如果在open的后面没有setRequestHeader()的话,会导致无法发送后面的数据。


相关文档:

jQuery AJAX 调用WCF服务实现的自动完成控件

代码下载:http://code.google.com/p/ajaxautocomplete/downloads/list
 
Auto Complete的jQuery控件。
首先是需要设计下我们的DIV最后应该显示成什么样子,我的CSS不咋地。瞎玩呢。样子如下:
首先是一个DIV,然后是添加一个ul和几个li tag:
<div id="nav">
<ul>
<li><a>Text1 field1& ......

ajax请求不返回html代码


ajax请求不返回html代码的三种方式
ajax请求代码:
function ajaxSend() {
$.ajax({
url: “Test_Ajax.aspx”,
type: “post”,
data: { name: “ajax” },//如果请求的自身页面,为了在后台判断是不是ajax请求
error: function(xhr, textStatus, errorThown) {
alert(errorThown) ......

第一个Ajax 实例

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>简单的应用XMLHt ......

Rails ajax 的联动的下拉框


# app\controllers\examples_controller.rb
ruby 代码
 
class ExamplesController < ApplicationController  
  
  def ajax_select  
    @items = %w{AA BB}  
  end   ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号