Reputation: 2214
As the title sais, I have this Javascript code:
$.ajax({
type: "GET",
url: "http://192.168.20.249/test.brick",
dataType: "json"
}).done(function() { alert("success"); }).fail(function() { alert("error"); }).always(function() { alert("complete"); });
My webserver sends these data:
200 OK
Date: Tue, 12 Mar 2013 07:49:51 GMT
Server: Hiawatha v8.8
Connection: keep-alive
Transfer-Encoding: chunked
Content-Type: application/json
{"Test": "Hello"}
Any idea why jQuery thinks the request failed?
Upvotes: 0
Views: 557
Reputation: 3643
Maybe you can use the error
callback to get som more info of what error jQuery sees?
$.ajax({
type: "GET",
url: "http://192.168.20.249/test.brick",
dataType: "json",
error: function(jqXHR, textStatus, errorThrown){
("error: " + textStatus); //Check all parameters in this callback
},
success: function(){
alert("success");
}
});
Edit: Cross domain ajax is not really as convenient as one would wish.
Upvotes: 0
Reputation: 1764
as your jquery script server and web server are different, it should be a cross-domain issue.
You should use jsonp for this communication.
Below is an example which can help you
http://www.jquery4u.com/json/jsonp-examples/
Upvotes: 1