我正在尝试向URL发送一个简单的请求(没有CGI参数),并让服务器返回一个复杂的(大约50k字节)对象。一切似乎工作正常,直到回复回来并调用.ajax.error()函数。 XHRs(jqXHR和$ .ajax()的返回值没有给出任何有用的信息,除此之外还有一个错误(见#2)。
我正在使用jQuery 1.9.1和jQuery-UI 1.10.3 抱歉,网址是为了安全起见。 sldn.com不是真正的域名和链接 以下将不起作用(除了对JQ ajax页面的引用)。
到目前为止我尝试过:
https:server.sldn.com:9007/bin/feed_status/feed_status.cgi
GET /bin/feed_status/feed_status.cgi HTTP/1.1
Host: server.sldn.com:9007
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: https:server.sldn.com:9007/feed_status/feed_status.html
Origin: https:server.sldn.com:9007
Connection: keep-alive
HTTP/1.1 200 OK
Date: Wed, 15 Jan 2014 20:19:09 GMT
Server: Apache/2.0.52 (Red Hat)
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json
Results passed to get_feed_status_json_error()
0 Object { readyState=0, status=0, statusText="error", more...}
readyState 0
responseText ""
status 0
statusText "error"
1 "error"
2 ""
this:
accepts Object { *="*/*", text="text/plain", html="text/html", more...}
async true
contentType "application/x-www-form-urlencoded; charset=UTF-8"
contents Object { xml=RegExp, html=RegExp, json=RegExp, more...}
converters Object { text html=true, * text=String(), text json=function(), more...}
crossDomain true
dataType "json"
dataTypes ["text", "json"]
flatOptions Object { url=true, context=true}
global true
hasContent false
isLocal false
jsonp "callback"
processData true
responseFields Object { xml="responseXML", text="responseText"}
type "GET"
url "https://server.sldn..._status/feed_status.cgi"
error function()
jsonpCallback function()
success function()
xhr createStandardXHR()
$( document ).ready(function() {
$( "#DatePicker" ).datepicker();
$("#debug_info_checkbox").prop("checked", false);
$("#debug_info_text").hide();
get_feed_status_json();
});
// This typically runs in the 7-10 second range.
function get_feed_status_json() {
var x =test_script();
$.ajax({
type: "GET",
url: "https://server.sldn.com:9007/bin/feed_status/feed_status.cgi",
dataType: "json",
success: get_feed_status_json_success,
error: get_feed_status_json_error,
});
}
var get_feed_status_json_success =
function(data, textStatus, jqXHR) {
alert("Got data!\\n" + textStatus);
return data;
};
var get_feed_status_json_error =
function(jqXHR, textStatus, errorThrown) {
alert("Got error: " + jqXHR.status);
};
function test_script() {
return '{"feeds":{"Big wad of json here"}';
}
有什么想法吗?
答案 0 :(得分:0)
足够简单。当我在浏览器中打开网页时,我只在地址栏中键入“server”而不是“server.sldn.com”,并让默认的DNS后缀找到它。
因此,为了避免使用jquery.ajax时遇到的特定版本的痛苦,请确保您的浏览器具有FQDN,否则它在跨源资源共享(CORS)方面存在问题。您可能希望将您的网站重定向到FQDN或类似的内容。