我试图向URL发送一个简单的请求(没有CGI参数),并让服务器返回一个复杂的(大约50K字节)对象。在回复返回并调用.ajax.error()函数之前,一切看起来都很好。XHR (jqXHR和从$.ajax()返回的值)并没有给出任何有用的信息,只表示存在错误(参见#2)。
我使用的是jQuery 1.9.1和jQuery-UI1.10.3对不起,URL是为了安全性而进行的。sldn.com不是真正的域,下面的链接将无法工作(除了对JQ页面的引用)。
到目前为止我尝试过的是:
1
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/json2
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()3.
$( 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"}';
}有什么想法吗?
发布于 2014-01-17 19:42:45
很简单。当我在浏览器中打开网页时,我只在地址栏中键入"server“而不是"server.sldn.com”,然后让默认的DNS后缀找到它。
因此,为了避免我使用jquery.ajax的特定版本,请确保您的浏览器有一个FQDN,否则它在跨源资源共享(CORS)方面有问题。您可能想让您的网站重定向到FQDN或类似的东西。
https://stackoverflow.com/questions/21162642
复制相似问题