Arkadaşlar,
beforeSend:.....
complete: ....
error: ....
kısımları malumunuz. Burada ek olarak normalde $.ajaxSetup içinde olmayan ve eklememize müsade ettiği "loadingTitle, loadingMessage" propları.
Bu propları ekledim ve erişmek için beforeSend içinde "this.xxxx" ile erişiyoruz.

Buna göre ajax çağrısı şöyle olacak:

$.ajaxSetup({
type: 'POST',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
loadingTitle: "Lütfen Bekleyiniz...",
loadingMessage : "İsteğiniz yerine getiriliyor",
beforeSend: function () {
this["loadingDialog"] = window["bootboxDialog"] = bootbox.dialog({
showLoading: true,
closeButton: false,
title: this.loadingTitle ,
message: this.loadingMessage
});
},
complete: function (XMLHttpRequest, textStatus) {
this["loadingDialog"].modal("hide");
},
error: function(error) {
alert(error.d);
if (error == "timeout") {
bootbox.dialog({
title: "ZAMAN AŞIMI",
message: "The request timed out, please resubmit. Tekrar deneyiniz."
});
} else {
var gelen = error.responseText;
Dialoglar.AlertHatali("HATA OLUŞTU", gelen.substr(12, gelen.indexOf("Stack") - 15), "");
}
if (error.responseText.indexOf("Unauthorized") > 0) {
Dialoglar.AlertHatali("YETKİSİZ KULLANICI", "The request failed with HTTP status 401: Unauthorized.", "SGK Kullanıcı adı ve şifrenizi kontrol ediniz");
} else if (error.responseText.indexOf("timeout") > 0) {
Dialoglar.AlertHatali("ZAMAN AŞIMI", "The request timed out, please resubmit", "Tekrar deneyiniz.");
} else {
var gelen = error.responseText;
Dialoglar.AlertHatali("HATA OLUŞTU", gelen.substr(12, gelen.indexOf("Stack") - 15));
}
}
});
Hiç yorum yok:
Yorum Gönder