首页 > 代码库 > 取得 Ajax 返回参数

取得 Ajax 返回参数

1  ajax 函数,p1 为正常函数    function ExecWebFunction(callback,p1) {             $.ajax({            type: "POST",            contentType: "application/json; charset=utf-8",            datatype: "json",            url: URL,            data: ajaxdata,            beforeSend: function (XMLHttpRequest) {                //Specifying this header ensures that the results will be returned as JSON.                XMLHttpRequest.setRequestHeader("Accept", "application/json");            },            success: function (data, textStatus, XmlHttpRequest) {                //成功执行语句                if (typeof callback === function) {                    callback("SUCCESS", data.d);                }                getresult(data.d);            },            error: function (XMLHttpRequest, textStatus, errorThrown) {                //错误执行语句                if (typeof callback === function) {                    callback("ERROR", textStatus);                }            }        });    }2 callback 函数--用来处理上面执行之后的事务.    function callback(info, result) {        if (info == "SUCCESS") {            //do somethings        }        else {          //do somethings        }    }3 调用方式如下:ExecWebFunction(callback,p1);

 

取得 Ajax 返回参数