我想实现简单的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");
});