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

Wow, I just read today that China has announced it would indefinitely postpone a mandate requiring all personal computers sold in the country to be accompanied by a controversial content-filtering application. If that software is in my desktop, I would be feeling uneasy knowing that everything I do, surf, type, whatever may not be possible in some cases because of that filtering. It is always good to know what is going on with your country and that filtering software will surely minimize content regarding politics. While its main purpose they say is to filter pornography, there will be other purposes not divulged to the public.




