对象#< XMLHtt prequest>有没有一种方法“做” [英] Object #<XMLHttpRequest> has no method 'done'

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

问题描述

我想实现简单的Ajax GET请求。在回调部分我想调用一些功能。在code是如下

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");
        });

但它显示出异常

But it is showing exception

未捕获的类型错误:对象#有没有方法'做'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 - 新版本返回的 jqXHR 对象,确实有完成
您可以通过查看源代码,或键入 $()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.

如果您不能升级,降级code应该是:

If you cannot upgrade, the downgraded code should be:

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

这篇关于对象#&LT; XMLHtt prequest&GT;有没有一种方法“做”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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