首页 > 代码库 > layout异步提交
layout异步提交
function Layout() { }
var layout = new Layout();
Layout.prototype.AjaxRequest = function (ActionInController, model, asyncType, callBack) {
var url = ActionInController;
$.ajax({
async: asyncType,
cache: false,
url: url, //请求的action路径
type: ‘POST‘,
data: JSON.stringify(model),
//dataType: "json",
contentType: "application/json,charset=utf-8",
beforeSend: function (e) {
//$(‘#main‘).html(‘‘);
},
error: function (e) { //请求失败处理函数
if (e.readyState == 4) {
layout.AjaxRequest(ActionInController, model, asyncType);
}
else {
alert(e.statusText + ", code:" + e.status);
return;
}
},
success: function (data) {
if (data =http://www.mamicode.com/="") {
layout.AjaxRequest(ActionInController, model, asyncType);
}
layout.onSuccessCallBack(data);
if (callBack != null) {
callBack();
}
},
complete: function (e) {
}
});
};
Layout.prototype.onSuccessCallBack = function onSuccessCallBack(data) {
$("#main").html(data);
};
layout异步提交