Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
697 views
in Technique[技术] by (71.8m points)

ajax - jQuery post respond with readyState:0, status:0

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"}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...