java
css
xml
ajax
database
ruby-on-rails
regex
visual-studio
multithreading
silverlight
flash
html5
json
perl
algorithm
cocoa
tsql
php5
asp
jsp
Define the function outside of document.ready, and use the overload of setInterval that takes a function reference:
document.ready
setInterval
var nameid = 1; function ajaxcall() { $.get('mysqlquery.php?id='+nameid, function(data){ $('#loadbox').append(data+' '); }); nameid++; } $(document).ready(function(){ $('button').click(function(){ ajaxcall(); }); setInterval(ajaxcall,1000); });
Call setInterval without the quotes for the function argument. (Preferred Method)
function
Example:
setInterval(ajaxcall, 1000);
If you're calling it with the quotes you need to include the parenthesis. But this forces eval() to be called.
eval()
setInterval("ajaxcall()", 1000);
The former is the preferred method.
Remove the quotes around "ajaxcall" to pass the actual function to setInterval.
or use the code below
replace setInterval line to
setInterval(function() { $.get('mysqlquery.php?id='+nameid, function(data){ $('#loadbox').append(data+' '); }); nameid++; }, 1000);
or use this
hoep this helps