ajaxSuccess未触发

时间:2010-11-12 07:47:00

标签: javascript jquery html ajax

我在下面有这个简短的代码,但ajaxSuccess没有被调用。知道为什么吗?

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

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

2 个答案:

答案 0 :(得分:2)

请改为尝试:

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

答案 1 :(得分:0)

通常我会将成功放在.ajax()调用中,但如果你这样做,看起来你需要在文档中指定选择器:

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