简体   繁体   中英

XmlHttpRequest not working on Mobile Browser

function ajaxify()
    {
     alert('stuff');
     xmlHttp = new XMLHttpRequest();
     xmlHttp.open('GET', 'page.php?params=' + params, true);
     xmlHttp.onreadystatechange = callbackFunction;
     xmlHttp.send();

    }

function callbackFunction(){
alert('called');
}

Never alerts "called", but does alert "stuff". Testing on iPhone 4.2.1 and Windows 7 Phone. Doesn't work on either. I'm told it works on newer phones. Works on desktop browser. The page is loaded, but the callbackFunction is never called. Any way of fixing this?

EDIT: Note, I also tried xmlHttp.onload , seems like the same issue.

You have a syntax error. forgot ' after params= :

xmlHttp.open( 'GET', 'page.php?params="' + params, true)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM