对象#< XMLHttpRequest>没有方法' done' [英] Object #<XMLHttpRequest> has no method 'done'

查看:92
本文介绍了对象#< XMLHttpRequest>没有方法' done'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现简单的ajax GET request.在回调部分,我想调用一些函数.代码如下

I was trying to implement simple ajax GET request . In the callback portion i want to call some function . The code is as below

$.ajax({
          url: "<?php echo SITE_URL?>ajax_pages/ajx_getcard.php?id="+obj.value,
          context: document.body
        }).done(function() { 
          $(this).addClass("done");
        });

但是它显示了异常

未捕获的TypeError:对象#没有方法完成" replace_entry.php:105 getCardno replace_entry.php:105 onblur replace_entry.php:118

Uncaught TypeError: Object # has no method 'done' replace_entry.php:105 getCardno replace_entry.php:105 onblur replace_entry.php:118

我正在使用谷歌浏览器

推荐答案

您可能正在使用旧版本的jQuery-新版本返回

You are probably using an old version of jQuery - new versions return a jqXHR object, that does have done.
You can quickly check your version by looking at the source, or typing $().jquery into your console.

如果无法升级,则降级的代码应为:

If you cannot upgrade, the downgraded code should be:

$.ajax({
      url: "...",
      context: document.body,
      complete: function() { 
           $(this).addClass("done");
      });

这篇关于对象#&lt; XMLHttpRequest&gt;没有方法&amp;#39; done&amp;#39;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆