jQuery AJAX 超时未定义

发布于 2024-09-12 10:04:03 字数 480 浏览 1 评论 0原文

我正在尝试示例 jQuery 示例,令我惊讶的是,我收到 AJAX 调用的错误状态,其中提到未定义超时。当我删除超时属性时,它工作得很好。 我几天前下载了 jQuery,所以我很确定这不是版本问题。

我尝试使用 Firefox(3.6.8) 而不是任何其他浏览器。

为什么会出现这种情况呢?

编辑:代码片段从评论移至问题

$.ajax({ 
  type: "GET", 
  dataType: 'json', 
  url: PHPServiceProxy, 
  timeout: 5000, 
  success: function(reply) { } // note: original code snippet provided was missing a comma here.
  error: function (xhr, textStatus, errorThrown) { } 
});

I was trying out example jQuery examples and to my surprise, I got an error state for an AJAX call mentioning that timeout isn't defined. When I removed timeout attribute, it worked fine.
I downloaded jQuery few days back, so I am pretty sure it's not a version problem.

I was trying with Firefox(3.6.8) and not any other browser.

Why would this occur?

Edit: Code snippet moved from the comments to the question

$.ajax({ 
  type: "GET", 
  dataType: 'json', 
  url: PHPServiceProxy, 
  timeout: 5000, 
  success: function(reply) { } // note: original code snippet provided was missing a comma here.
  error: function (xhr, textStatus, errorThrown) { } 
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

比忠 2024-09-19 10:04:03

timeout 属性已经在 jQuery 中存在很长时间了,所以我认为你的问题与它无关。也许您的代码中有语法错误。这应该有效:

$.ajax({ 
    type: 'GET', 
    dataType: 'json', 
    url: PHPServiceProxy, 
    timeout: 5000, 
    success: function(reply) { 

    },
    error: function (xhr, textStatus, errorThrown) { 

    } 
});

The timeout property has been present in jQuery for a long time so I don't think that your problem is related to it. Maybe you have a syntax error in your code. This should work:

$.ajax({ 
    type: 'GET', 
    dataType: 'json', 
    url: PHPServiceProxy, 
    timeout: 5000, 
    success: function(reply) { 

    },
    error: function (xhr, textStatus, errorThrown) { 

    } 
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文