Auto Update HTML Tags Using Ajax

function loadWeather() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { // change content from div document.getElementById("weather_updates").innerHTML = xmlhttp.responseText; setTimeout(loadWeather(),100); } } xmlhttp.open("GET", "includes/weather.php", true); xmlhttp.send(); } loadWeather();

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.