最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Object #<XMLHttpRequest> has no method 'done' - Stack Overflow

programmeradmin0浏览0评论

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

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

I am using google chrome

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

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

I am using google chrome

Share Improve this question asked Sep 11, 2012 at 6:03 hangmanhangman 8755 gold badges21 silver badges31 bronze badges 1
  • which version of jquery are you using? – Sandeep G B Commented Sep 11, 2012 at 6:14
Add a comment  | 

2 Answers 2

Reset to default 17

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

Replace the done with success..??

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

评论列表(0)

  1. 暂无评论