I need Ajax script that will check every 5 seconds, the contents of file.php
file.php may contain only true
or false
.
If true - script must perform an action. if false - script should continue to check the file for true
how to make it?
I need Ajax script that will check every 5 seconds, the contents of file.php
file.php may contain only true
or false
.
If true - script must perform an action. if false - script should continue to check the file for true
how to make it?
For a starting point ave a look at this -> http://api.jquery.com/jQuery.get/
Example: Gets the test.php page contents, which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>
), and adds it to the page.
$.get("test.php",
function(data){
$('body').append( "Name: " + data.name ) // John
.append( "Time: " + data.time ); // 2pm
}, "json");
To repeat something every # seconds have a look at the setInterval function :
Calls a function repeatedly, with a fixed time delay between each call to that function.
Then when you have created some code - come back and post your issues
will this help?
Call js-function using JQuery timer
then use jquery ajax methods. http://api.jquery.com/jQuery.ajax/
I would help you more but you need to first help your self.
You just need to perform regular $.ajax call inside setInterval. Maybe clearInterval would be useful too, if you want to stop checking remote file.