[英]jQuery getJSON Never Calls Success Function When Successful
I am using jQuery to retrieve json data from a server. 我正在使用jQuery从服务器检索json数据。 The server responds with a json-encoded object. 服务器以json编码的对象作为响应。 The problem is, after the server responds, my success function does not get called. 问题是,服务器响应后,不会调用我的成功函数。
Here is my request: 这是我的要求:
$('form').on('submit', function(event) {
event.preventDefault();
$.getJSON('?getAvailableRoom', function(data, textStatus, jqXHR) {
alert("Success!"); // doesn't happen
});
});
Here is the response from the server: 这是服务器的响应:
Response Headers
Content-Type application/json
Date Mon, 09 Jul 2012 20:02:10 GMT
Transfer-Encoding chunked
Via 1.1 teleproxy01 (NetCache NetApp/6.0.3P2D5)
Request Headers
Accept application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Host XXXXX
Proxy-Connection keep-alive
Referer XXXXX
User-Agent Mozilla/5.0 (Windows NT 5.2; rv:13.0) Gecko/20100101 Firefox/13.0.1
X-Requested-With XMLHttpRequest
Response
{'id':'AsuRC'}
Your JSON is invalid. 您的JSON无效。
It should be: 它应该是:
Response
{"id":"AsuRC"}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.