注意:dType "htm","xml","json" ,如果返回的数据没有对应dType所指定的类型,那么$.ajax对象将会回调error函数
function ExectueSc(myUrl, argObj, waitObj,dType) {
var obj;
if (!dType) {
dType = "json";
}
$.ajax({
cache: false,
async: false,
dataType: dType,
type: "POST",
url: myUrl,
beforeSend: this.ExectueScWait(waitObj),
data: argObj,
success: function(ret) {
obj = ret;
},
error: function() {
obj = '网络连接错误!';
}
});
return obj;
}
function ExectueScWait(waitObj) {
document.getElementById(waitObj).innerHTML = '<img src="http://www.cnblogs.com/img/loading55.gif"/>请稍后...';
}