I have this code:
$(document).ready(function(){
var callPage = function(){
$.post('/pageToCall.php');
};
setInterval('callPage()', 60000);
});
and it gives me the error ReferenceError: Can't find variable: callPage. Why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try
setInterval(callPage, 60000);.If you pass a string to
setInterval, then this string is evaluated in global scope. The problem is thatcallPageis local to thereadycallback, it is not global.There is hardly ever a reason to pass a string to
setInterval(setTimeout). Always pass a function (to avoid exactly this kind of errors).