Is this possible? I need to get some data from another phpfile and I want it to appear every X seconds without you having to refresh the page.
2 Answers
Yes, that is known as "polling" or "periodic refresh"
You can use setInterval (see @Luca's answer) and jQuery's ajax API to communicate with the PHP file, and jQuery's DOM manipulation API to change the contents of the page. In its simplest form:
setInterval(function(){ $.get('ajax.php', function(data) { $('.result').html(data); alert('Load was performed.'); }); }, 5000); // 5 seconds Comments
Sure you can. Use setInterval to execute something every x milliseconds.
setInterval(function(){ // your code }, 5000); // 5 seconds 1 Comment
Kraffs
I'm completely horrible with javascript and jquery, How do I get the content from a PHP file?