Php – how to update the every sec in jquery

jqueryPHP

I am trying to get the data from the php file and update every second so when the information changes in the php file it will auto update

 $(document).ready(function() { 
$.ajaxSetup ({
    cache: false
});
 $("#hidden").hide(); 
 $("#textfield").val(""); 
 $("#textarea").val(""); 

 var hol=$(this).attr('myval'); 
 var formContent ="action=getlink&link="+hol; 

 $.getJSON("inc/json.php",formContent, function(json){ 
 $("#textfield").val(json.name); 
 $("#textarea").val(json.desc); 
 $("#formHeader").text("Edit"); 
 $("#ajaxBox").text("All info loaded OK"); 
 });


 });

Best Answer

Use setInterval(), not setTimeout(). setInterval will call the function at your specified interval.

var interval = setInterval(function() { 
    /* do something that will execute every 1000 milliseconds*/ 
}, 1000);