Use Javascript to retrieve HTML on same-domain
Posted
by
ehfeng
on Stack Overflow
See other posts from Stack Overflow
or by ehfeng
Published on 2011-01-03T11:35:05Z
Indexed on
2011/01/03
11:53 UTC
Read the original article
Hit count: 353
JavaScript
|javascript-events
Say I have an xml document on a webserver (www.example.com/example.xml). On my main page, if I would like to retrieve that document as a string, how can I do this?
I tried xmlhttprequest - maybe I'm using it wrong? It returns it as "undefined." Help?
var xml_page = new XMLHttpRequest(); xml_page.open("GET", "http://www.samedomain.com/example.xml", true); if (xml_page.readyState == 4 && xml_page.status == 200) { var data = xml_page.responseText; } document.write(data);
© Stack Overflow or respective owner