Loading Content Of Page Using AJAX
Posted by tech on
June 30, 2009
You can load the contents of a page inside an HTML layer element using AJAX with this function. The url parameter can accept querystrings of dynamic pages.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | function get_content(url, div_id) { var req; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if (req != undefined) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if req is "loaded" if (req.status == 200) { // only if "OK" document.getElementById(div_id).innerHTML = req.responseText; } } }; req.open("GET", url, true); req.send(""); } } |











July 1st, 2009 at 2:09 am
[...] See the original post here: Loading Content Of Page Using AJAX [...]