beanymanuk Posted December 13, 2012 Share Posted December 13, 2012 Hi I'm trying to output a response which is xml but its only displaying in the alert box and not in the div and I'm not sure what I'm doing wrong any idea's var request; function callback() { if (request.readyState == 4) { try { if (request.status != 200) { alert('error'); } else { // ok, process... document.getElementById("myDiv").innerHTML= request.responseText; alert("got data: "+request.responseText); } } catch(e) { alert('error'); } } } function test_get() { request = new CrossXHR(); request.onreadystatechange = callback; request.open('GET', 'http://www.gamerservices.co.uk/jackpot_obs_xml.xml'); request.send(); } Quote Link to comment https://forums.phpfreaks.com/topic/271947-outputting-xml-response/ Share on other sites More sharing options...
trq Posted December 13, 2012 Share Posted December 13, 2012 Programs only do what you tell them to do. Your calling the alert method. Quote Link to comment https://forums.phpfreaks.com/topic/271947-outputting-xml-response/#findComment-1399122 Share on other sites More sharing options...
beanymanuk Posted December 13, 2012 Author Share Posted December 13, 2012 yeah I'm trying to output to div I have set up document.getElementById("myDiv").innerHTML= request.responseText; Quote Link to comment https://forums.phpfreaks.com/topic/271947-outputting-xml-response/#findComment-1399124 Share on other sites More sharing options...
Christian F. Posted December 13, 2012 Share Posted December 13, 2012 Alert the result of document.getElementById("myDiv") first, to see if you get what you expect. Then alert the .innerHTML property. Quote Link to comment https://forums.phpfreaks.com/topic/271947-outputting-xml-response/#findComment-1399127 Share on other sites More sharing options...
beanymanuk Posted December 13, 2012 Author Share Posted December 13, 2012 I just get the hardcoded text got data: outputting in my div and not the response request.responseText which appears ok in the alert box Quote Link to comment https://forums.phpfreaks.com/topic/271947-outputting-xml-response/#findComment-1399133 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.