$.Ajax.Request(url,method,parameters,onComplete,onError)

发送异步请求。

参数

url
必选项。数据发送的目标地址。
method
可选项。数据提交的方式,默认值为get。常用的还有post。
parameters
当 method 为 get 时是可选项,为 post 时是必选项。发送的数据,其形式为: name1=valeu1& name2=value2&name3=value3......
onComplete
可选项。请求成功时执行的回调函数,该函数默认把当前使用 xmlhttp 对象作为第一个参数。
onError
可选项。请求异常时执行的回调函数,该函数默认把当前使用 xmlhttp 对象作为第一个参数。

返回值

当前使用的 xmlhttp 对象。

描述

发送异步请求,并返回 xmlhttp 对象,请求成功则执行 onComplete,失败则执行 onError
$.Ajax.Request 是 Ajax.Request 方法的快捷调用方法,接口参数不能设置不常用的 setRequestHeader 。

示例

<script type="text/javascript" >
function doneFun(xmlhttp){
     document.write( xmlhttp.responseText);
}
function errFun(xmlhttp){
     alert( "ERROR! \r\n error code: "+xmlhttp.status + "\r\n error text:" + xmlhttp.statusText);
}
var xmlHandle = $.Ajax.Request("http://www.google.cn/search","get","complete=1&hl=zh-CN&q=myJSFrame&meta=&aq=null",doneFun,errFun);
</script>