码迷,mamicode.com
首页 > 其他好文 > 详细

layout异步提交

时间:2015-01-26 20:36:16      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:

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 == "") {
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异步提交

标签:

原文地址:http://www.cnblogs.com/csharphuang/p/4251060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!