When I make a request to a web service using the jquery function : $.ajax
, it works fine on android, but on iOS, when the response from the server is 4**/5**
, the request stay in pending.
This is the function which perform a get request :
var ajaxGetJson = function(url) {
return $.ajax({
type: "GET",
url: url,
dataType: 'json',
headers: JSON.parse(localStorage.getItem(App.keys.KEY_STORAGE_CREDENTIAL))
});
};
So, i tried to fix it with something like that :
var ajaxGetJson = function(url) {
jqXHR = $.ajax({
type: "GET",
url: url,
dataType: 'json',
headers: JSON.parse(localStorage.getItem(App.keys.KEY_STORAGE_CREDENTIAL))
});
if (jqXHR.state() == 'pending') {
jqXHR.abort();
}
return jqXHR;
};
It actually works when the response is a 404
, but when it should be a 200
, the function abort the request and go to the error part.
Why does the request stay in pending only for iOS ? I can't figure it out.
Thanks for helping me, and my apologies for the english.