HI,
I having an issue consuming a RESTful service build in Java.
When I create an Ajax Call to a service I don't get any response (nor failure, nor success).
I have test this issue using jQuery and directly using XMLHttpRequest and I have the same behaviour.
$.ajax({
type: "GET",
url: appBaseURL + "service" + cookie,
contentType: "application/json; charset=utf-8",
dataType: "json",
timeout: 10000,
}).
done(function(){console.log("All done");}).
fail(function(){console.log("It fail");}).
always(function(){console.log("Complete");});
var xhrManual = new XMLHttpRequest();
xhrManual.onreadystatechange = function()
{
console.log("Ready State: " + xhrManual.readyState);
if ( xhrManual.readyState == 4) {
console.log("Ready State 4");
}
}
xhrManual.open("GET",appBaseURL + "service" + cookie,true);
xhrManual.setRequestHeader('Content-type', 'application/json; charset=utf-8');
xhrManual.send();
I have tried the following workaround without any luck.
Tested it using the latest version of phonegap (cordova.js 3.0.0-0-ge670de9 and 2.9.0-0-g83dc4bd)
Used jquery 1.10 and 1.11 (I know now that this has nothing to do...)
I believe the issue is related with the returned data. But it doesn't have to do with null; sometimes it fails when the structure is more complex.
If I return this, it doesn't work
[
{"field1":"value1","field2":null},
{"field1":"value1","field2":null},
{"field1":"value1","field2":null}
]
If I return the following it works!
[
{"field1":"value1","field2":""},
{"field1":"value1","field2":""},
{"field1":"value1","field2":""}
]
I have captured the network request using safari web inspector and I get a status 200.

I have tested this in browsers and in Android and it works ok!
Any idea?