Jump to content


Photo

Outputting Xml Response

xml response javascript

  • Please log in to reply
4 replies to this topic

#1 beanymanuk

beanymanuk

    Advanced Member

  • Members
  • PipPipPip
  • 104 posts

Posted 13 December 2012 - 05:56 AM

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();
}


#2 trq

trq

    Advanced Member

  • Administrators
  • 31,023 posts
  • LocationSydney, Australia.

Posted 13 December 2012 - 06:08 AM

Programs only do what you tell them to do. Your calling the alert method.

http://thorpesystems.com | http://proemframework.org | http://github.com/trq

SmtpCatcher - A very simple mock sendmail useful for testing PHP mail scripts.
OPM - My Linux package manager.


#3 beanymanuk

beanymanuk

    Advanced Member

  • Members
  • PipPipPip
  • 104 posts

Posted 13 December 2012 - 06:19 AM

yeah I'm trying to output to div I have set up
document.getElementById("myDiv").innerHTML= request.responseText;


#4 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 13 December 2012 - 06:49 AM

Alert the result of document.getElementById("myDiv") first, to see if you get what you expect. Then alert the .innerHTML property.
Keeping it simple.

#5 beanymanuk

beanymanuk

    Advanced Member

  • Members
  • PipPipPip
  • 104 posts

Posted 13 December 2012 - 07:02 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com