对象#< XMLHttpRequest>没有方法&#39; done&#39; [英] Object #&lt;XMLHttpRequest&gt; has no method &#39;done&#39;
问题描述
我正在尝试实现简单的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
我正在使用谷歌浏览器
推荐答案
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");
});
这篇关于对象#< XMLHttpRequest>没有方法&#39; done&#39;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!