XML HTTP Reuqest Parsing For Div Id (JavaScript)

tonileonar

New Member
HTML File: index.html\[code\]<html><head><title>UI Test: Main Menu</title><script type="text/javascript" src="http://stackoverflow.com/questions/11223372/general.js"></script></head><body onload="test();"> <div id="mainContainer"></div></body> </html>\[/code\]HTML File: indexWelcome.html\[code\]<div id="test"><center><h3>Test Menu</h3></center><br></div><div id="test2"><center><h3>Main Menu</h3></center><br></div>\[/code\]Javascript: general.js\[code\]function test() {var xmlhttp = new XMLHttpRequest(); //Creating XML request objectxmlhttp.open("GET", "indexWelcome.html", true); //Telling it what to getxmlhttp.onreadystatechange = function() { //Function for when it gets a response if (xmlhttp.readyState == 4) { //If its ready alert(xmlhttp.responseText) //Alert contents of opject var html = xmlhttp.responseText; alert(document.createElementNS('test')); }}xmlhttp.send(null)}\[/code\]I am having to do it this way rather than just simply using JQuery because the device im developing for doesn't support AJAX , I have been able to load a full page with this code, but I am not able just to load say "test" div from the page rather than the full thing...How would I do this? Am I best to load it all then parse it(preferably not as that would be using more memory and in a large file this could cause issues)Or can I load only the bit I want?Also I must add I've seen some ways to parse, but that requires know the content of the whole thing you want to parse first which i wont as it could be changed at any time but the ID of the div and page will always remain the same.Thanks for your help/support people :)
 
Back
Top