javascript - AJAX Fails on Mobile -


i having issue ajax requests on mobile browsers (and ipads, etc) works fine on desktop computers. @ complete loss work out what's wrong here.

var xmlhttp; if(window.xmlhttprequest){     xmlhttp = new xmlhttprequest(); }else{     xmlhttp = new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange = function(){     if (xmlhttp.readystate == xmlhttprequest.done ){        if(xmlhttp.status == 200){             console.log(xmlhttp.responsetext);        }else{            alert("status "+xmlhttp.status);        }     } } xmlhttp.open("get","http://www.mywebsite.co.uk/assets/php/upvote.php?id="+id,true); xmlhttp.send(); 

i've tried: xmlhttp.open("get","/assets/php/upvote.php?id="+id,true); , xmlhttp.open("get","../php/upvote.php?id="+id,true); 3 of work on desktop computer (console logs success message) on mobile devices alerts "status 0".

i can't work out why works fine on desktops xmlhttp.status 0 on mobiles.

ok, help!

i loaded ios safari devtools , watched console. getting cross site scripting issue though i'd changed path '/assets/php/...'.

this due .htaccess file forcing traffic through 'www.' wasn't acting on both directories initial webpage , ajax files in (so path did , paths didn't have 'www.').

i've updated .htaccess (which reason wasn't acting on ios safari requests desktop chrome ones) , works fine!


Comments