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);