- ajaxStart (Global Event)
- beforeSend (Local Event)
- ajaxSend (Global Event)
- success (Local Event)
- ajaxSuccess (Global Event)
- error (Local Event)
- ajaxError (Global Event)
- complete (Local Event)
- ajaxComplete (Global Event)
- ajaxStop (Global Event)
Local 事件
$.ajax({
beforeSend: function(){
// ......
},
complete: function(){
// ......
}
// ......
});
Global 事件
$(document).bind("ajaxSend", function(){
// ......
}).bind("ajaxComplete", function(){
// ......
});
/**OR**/
$(document).ajaxStart(function () {
// ......
}).ajaxStop(function () {
// ......
});
Global 事件禁用
$.ajax({
url: "test.html",
global: false,
// ......
});
範例-Ajax 讀取中
$.ajax({
beforeSend: function(){
$("#loading_msg").text("庫存讀取中...");
},
complete: function(){
$("#loading_msg").text("");
}
// ......
});
/**OR**/
$(document).ajaxStart(function () {
$("#loading_msg").text("庫存讀取中...");
}).ajaxStop(function () {
$("#loading_msg").text("");
});
沒有留言:
張貼留言