javascript - Website working, but not on iphone. XMLHttpRequest() error -


i have created website

http://www.tylertracy.com/testing/xml/app%20veiwer%205-28.php

it works fine on browsers , on iphone simulators, doesn't work on real iphone. have narrowed down xmlhttprequest(). seems when getting xml, can not read children of [object element] returns undefined. baffling not understand.

here code getting xml

function convertxml (path) {     if (window.xmlhttprequest){         xmlhttp=new xmlhttprequest(); // code ie7+, firefox, chrome, opera, safari     }else{         xmlhttp=new activexobject("microsoft.xmlhttp"); // code ie6, ie5     }     xmlhttp.open("get",path,false);     xmlhttp.send();     xml=xmlhttp.responsexml.getelementsbytagname("app");     var foo = [];     (var = 0; <= xml.length-1; i++) {         foo[i] = {};         (var j = 0; j <=xml[i].children.length-1; j++) { // children of app , make part in object             foo[i][xml[i].children[j].tagname] = xml[i].children[j].innerhtml.trim();//super complicated         }       }     return foo; } 

after experimenting have discovered on iphone request returns [object document] while computer returns [object xmldocument]. don't know means, feel problem coming from. there way of maybe converting between these?

i have since updated code jquery seeing if issue still persists, does.

here new jquery

function getxml (path) { //gets text version of xml doc var response = $.ajax({ type: "get",                        url: "testingxml.xml",                        async: false,                   }).responsetext; //converts text xmldoc parser=new domparser(); xmldoc=parser.parsefromstring(response,"text/xml"); return xmldoc; }  function xmltoobject (x) { var xml = x.getelementsbytagname("app"); //get xml root var foo = []; (var = 0; <= xml.length-1; i++) {     foo[i] = {}; // make object     (var j = 0; j <=xml[i].children.length-1; j++) { //get of children of main tag         foo[i][xml[i].children[j].tagname] = xml[i].children[j].innerhtml.trim();  //super complicated     } } return foo; } 

then array, write code xmltoobject(getxml("testingxml.xml"))

the issue still happening, on computer fine, on iphone (google, safari, firefox, oprah) seems xml isn't displaying.

i'm getting

synchronous xmlhttprequest on main thread deprecated because of detrimental effects end user's experience. more help, check http://xhr.spec.whatwg.org/

in google chrome console when opening page. why won't load on ios: instead of logging warning, apple decided ignore such requests on mobile devices prevent browser freezing.

try with

xmlhttp.open("get",path,true); 

and xhr.onload handler described in mdn's "synchronous , asynchronous requests".


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -