开发者

ajaxSuccess not triggered

I have this short and simple code below but ajaxSuccess didn't get called. Any idea why?

$.ajax({
 type: "GET",
 async: true,
 url: "/userprofile",
 data: {
  'username': username
 },
开发者_C百科        error: function (xhr, status, error){
        }
}); 

$().ajaxSuccess(function(event, request, settings) {
alert("OK");
});


Try this instead:

$.ajax({
 type: "GET",
 async: true,
 url: "/userprofile",
 data: {
  'username': username
 },
 success:function(res){
   alert(res);
 },
 error: function (xhr, status, error){
   /////
 }
}); 


usually i will put the success inside the .ajax() call, but if you do it this way, it seems like you need to specify the selector as in the docs:

http://api.jquery.com/ajaxSuccess/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜