【问题标题】:jQuery Ajax function returns error: Uncaught TypeError: Object #<XMLHttpRequest> has no method 'done'jQuery Ajax 函数返回错误:Uncaught TypeError: Object #<XMLHttpRequest> has no method 'done'
【发布时间】:2012-10-11 22:42:11
【问题描述】:

我在使用 jQuery 的 ajax 函数时总是报错:

Uncaught TypeError: Object # has no method 'done'

让我感到困惑的是,它在过去 3 天里运行良好。而且我做了一些更改,所以我想这一定是我的错,但它没有返回语法错误,就像它告诉我 jquery ajax 函数错误一样,那不可能?

$.ajax({
    type: "POST",
    url: "ajax/cms.php",
    data: {
        job: 'edit_staff',
        id: id,
        name: staff_name,
        description: staff_description
    }
}).done(function(returned)
{
    var message = 
    $('<div class = "edit_status_message_fees">' + '<span>Success: </span>' + returned + '</div>');
    message.appendTo('.edit_team');

    $('.edit_status_message_fees')
    .fadeIn('normal',
    function()
    {
        if(returned == "Database updated!")
        {
            $.post('ajax/get_new_staff_details.php', function(new_team)
            {
                $('.theteam').html(new_team); // Update main content area
            });

            $('.edit_team')
            .delay('500')
            .fadeOut('normal', function()
            {
                $('.edit_team').remove();
            })

            $('.list_team')
            .delay('500')
            .fadeOut('normal', function()
            {
                $('.list_team').remove();
            })

            $('.edit_cover')
            .delay('500')
            .fadeOut('normal', function()
            {
                $('.edit_team').remove();
            })
        }

    })
}); // END ajax

有人可以帮帮我吗?

【问题讨论】:

  • 所有浏览器都会出现这种情况,还是只出现在 IE 中?
  • 另外,as mentioned here,请确保您使用的是 1.5 或更高版本的 jQuery。

标签: jquery ajax


【解决方案1】:

我相信你使用的是旧的 jQuery 版本,升级它,或者做这样的事情:

 $.ajax({
      url: "ajax/cms.php",

      ...

      complete: function() { 
        //your callback body
      }
});

【讨论】:

  • 我尝试并测试了不同的版本。一切似乎都带来了问题。最后我只是切换到更具体的 $.Post ajax 函数。这似乎可以解决问题,但谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多