I'm having a Node.js express app.
On a specific view, I have a recurrent ajax post-call, which is checking the status of a process. On the response, if it needs to be checked again there is a timeout of 5 seconds before checking again.
It's working well on the desktop and mobile none IOS However, as soon as I tried it on an iOS mobile it failed on the third request. (the first two worked well)
I checked different browser on the iPhone and each time is the same.
I'm having the following response from the call
{"readyState": 0, "status":0, "statusText": "error"}
It seems to be the case on every iOS devices. But it's working everywhere else (android, windows) Any ideas where it could come from? Very weird that it's happening working well for the first two calls and then somehow get blocked.
JS CODE OF THE REQUEST :
const checkUpdate = (amount, ref, status) => {
$.post({
type: "POST",
url: "/check-update-transaction",
data: { amount, ref, status},
headers: {
"CSRF-Token": token,
},
}).done(
(res) => {
console.log(JSON.stringify(res));
setTimeout(() => {
switch (parseInt(res.status)) {
case 1:
return checkUpdate(amount, ref, 1);
case 2:
return checkUpdate(amount, ref, 2);
case 3:
$("#circle-loader-popup").hide();
return true;
}
}, 5000);
}
).fail((error) => {
$(".status-information .main-content-loader")
.html(`A problem happened during the submission please try again `);
console.log(JSON.stringify(error));
if(error.responseJSON && error.responseJSON.notFind === true){
$("#after-first-step").hide();
}
});
};
Thanks in advance,
Anselme