I have a simple restful service that returns a json. I want to make an ajax call to get required data. When I try with firefox's RestClient there is no problem. Service returns the json and I can see the json on rest client. But when I use ajax call it fails. The console shows 200 OK
, but the error function executes after the call. I searched for this, commonly they say that its a cross domain problem but I fail to solve this.
This is the fail message of error function {"readyState":0,"responseText":"","status":0,"statusText":"error"}
AJAX call
$.ajax({
type:"GET",
url: "http://localhost:8080/myController/getInfo",
dataType:"json",
success: function(data){
alert(JSON.stringify(data));
},
error: function(msg){
alert("ERROR! \n" + JSON.stringify(msg));
}
});
Firefox's console message
Content-Type application/json
Date Mon, 18 Feb 2013 11:51:41 GMT
Server Apache-Coyote/1.1
Transfer-Encoding chunked
Accept application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language tr-TR,tr;q=0.8,en-US;q=0.5,en;q=0.3
Host localhost:8080
Origin null
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0
The data returned from the call:
{ "date": "1 hour ago", "photoUrl": "img/movie_detail/celal.jpg", "rating": "three", "title": "Celal ile Ceren" }