Here is a quick little snippet on refreshing a PHP script into an HTML page element using AJAX and automating it with setInterval:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
prices(); function prices() { $.ajax({ type: "GET", url: "inc/load_prices.php", cache: false, success: function(response){ $("#prices").hide().html(response).fadeIn(500); } }); } setInterval(prices, 600000); |
Here we run the prices() function, GET the load_prices.php file and then upon success place the response into the #prices <div> element on the page. The automate potion is handled by setInterval and triggered every 600,000 milliseconds. Easy!