日期:2014-05-16 浏览次数:20772 次
Ajax.Request( url, { method:method, parameters:para,//HTTP请求的查询字符串 postBody:xmlString, asynchronous:true, setRequestHeader:Object, onComplete:showResponse, onError:errorFun } )
<script type="text/javascript" > var myAjax = new Ajax.Request( "http://www.happyshow.org/form.asp", { method:"post", //表单提交方式 parameters:"name=acai&age=26&sex=male", //提交的表单数据 setRequestHeader:{"If-Modified-Since":"0"}, //禁止读取缓存数据 onComplete:function(x){ //提交成功回调 alert(x.responseText); }, onError:function(x){ //提交失败回调 alert(x.statusText); } } ); </script>
<script type="text/javascript" > var xmlString = "<root>" +"<people><name>caizhongqi</name><sex>male</sex></people>" +"<people><name>ahuang</name><sex>female</sex></people>" +" </root>"; var myAjax = new Ajax.Request( "http://www.happyshow.org/xmlform.asp", { method:"post", //表单提交方式 postBody:xmlString, //提交的xml setRequestHeader:{"content-Type":"text/xml"}, //指定发送的数据为 xml 文档(非字符串) onComplete:function(x){ //提交成功回调 alert(x.responseXML.xml); }, onError:function(x){ //提交失败回调 alert(x.statusText); } } ); </script>