HTML JS on iOS
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
epergola · 2020-12-15 15:35
I hope ther is someone expert on this topic.
I have this code. It works fine in Android Chrome. In iOS resp shows
"undefined".
async function submitfuncR(resp,saveterminal){
alert(resp); THIS SHOWS "UNDEFINED" in iOS
............
}
async function submitfunc(submitfuncR) {
var xhr = new XMLHttpRequest;
xhr.onreadystatechange=function(){
if (xhr.readyState === 4 && (xhr.status ===200 ) {
...........
resp=xhr.response;
submitfuncR(resp,saveterminal);
}
}
xhr.open("POST",_serverpar,true);
xhr.send("login;");
return false;
}
It is called in the body section like this:
----------------------------------------------------------------------
lainz · 2020-12-15 23:51
Try evaluating resp = xhr.response, if is undefined or not before you
send it to submitfuncR
----------------------------------------------------------------------
epergola · 2020-12-16 19:02
Thanks Lainz.
Of course I did. It does show xhr.response just before the call to
submitR, but it shows undefined in the first line of that function. I
repat shows ok in Android Chrome, but it fails on iOS Chrome.
----------------------------------------------------------------------
lainz · 2020-12-17 01:28
Cross plataform bugs even in the web...
What if you make a real copy of the response? Or just the data you
need to see and pass that?
Edit: I said that because I don't know the data type of the response.
Also I noticed that you forget to put var before resp assignment. Not
sure if that does something on iOS. Like by default strict mode or
something...