javascript - setInterval does not call a functions after the specified time -



javascript - setInterval does not call a functions after the specified time -

this question has reply here:

why function phone call should scheduled settimeout executed immediately? [duplicate] 3 answers

inside 1 js function phone call another,.. want phone call every 30 seconds

function showpopup() { $.get("/feedback.aspx", function (data) { if (post_haserror(data)) return; initpopup("popup-common", "feedback", data); }); setinterval(addformtosession(3), 30000); } function addformtosession(form) { alert(1); var url1 = form == 3 ? "feedback.aspx/addformtosession" : "request.aspx/addformtosession"; $.ajax ({ type: "post", async: true, url: url1, data: "{'funcparam':'" + $('#aspnetform').serialize() + "'}", contenttype: "application/json; charset=utf-8", datatype: "json", success: function(msg) { console.log(msg.d); } }); }

is called first time

you not phone call function in first argument of setinterval. calling function returns value function, not reference function. in case, returning undefined.

you pass reference of function. may utilize anonymous function , phone call there.

setinterval(function () { addformtosession(3); }, 30000);

from comments:

the function object passed, not "reference" a function phone call first argument fine if returns function.

javascript setinterval

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -