jQuery的响应后与readyState的:0,状态:0 [英] jQuery post respond with readyState:0, status:0

查看:758
本文介绍了jQuery的响应后与readyState的:0,状态:0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有。我使用的是jQuery的版本1.6.2。 我不喜欢这样的Ajax调用:

  VAR jqxhr = $ j.post(myPHP,函数(){
          警报(成功);
        })
        .success(函数(){警报(第二个成功);})
        .error(功能(数据){警报(JSON.stringify(数据));})
        .complete(函数(){警报(完成);});
 

该脚本,运行,并显示错误,不是,完整。有些人可能会件事...... myPHP有一些问题,但myPHP总是显示:

  {sayHi的:日冰}
 

所以,我去firebugs检查网络连接是否有任何问题,当我叫..: 它给我的帖子的网址,状态为200,这是确定的。另外,我可以看到通过firebugs的回应.... 但问题是....为什么如此的jQuery我有一个错误...: 这里是错误信息:

  {readyState的0的responseText:,状态:0,状态文本:错误}
 

解决方案

对于我这个问题是由一个跨域问题引起的。 所以我有一个本地的HTML文件( C:\ test.html的),并试图从服务器(本地主机/ servlet的)获取数据。 当把HTML服务器 - 问题就消失了。

all. I am using a jquery version 1.6.2. I do a ajax call like this:

  var jqxhr = $j.post(myPHP, function() {
          alert("success");
        })
        .success(function() { alert("second success"); })
        .error(function(data) { alert(JSON.stringify(data)); })
        .complete(function() { alert("complete"); });

The script, run, and show error, than, complete. Some people may thing that...myPHP have some problem, but the myPHP is always show:

{"sayHi":"hihi"}

So, I go to firebugs to check whether the link have any problem, when I called..: It show me the POST url with status 200, which is ok. Also, I can see the respond via firebugs.... But the question is ....why the jquery so me have a error...: And here is the error msg:

{"readyState":0,"responseText":"","status":0,"statusText":"error"}

解决方案

For me this problem was caused by a cross-domain issue. So I had a local html file (c:\test.html) and tried to get data from a server (localhost/servlet). When putting html on the server - the problem was gone.

这篇关于jQuery的响应后与readyState的:0,状态:0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆