Javascript Error Useless Setinterval Call
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta pass parameters to setinterval function Discuss the workings and policies of this site About Us Learn
Setinterval Mdn
more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us function bind javascript Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like javascript clearinterval you, helping each other. Join them; it only takes a minute: Sign up Javascript setinterval function with arguments up vote 6 down vote favorite 2 How do I pass arguments in the setInterval function Eg: intId = setInterval(waiting(argument), 10000); It shows error : useless setInterval call (missing quotes around argument?) javascript share|improve this question asked Mar 14
Stop Setinterval
'13 at 13:17 user1871640 1482413 1 setInterval(function(){waiting(argument)}, 10000) –rab Mar 14 '13 at 13:19 possible duplicate of Pass parameters in setInterval function –416E64726577 Apr 8 '14 at 21:29 do a simple search first! –Jonatas Walker May 25 '15 at 13:40 add a comment| 5 Answers 5 active oldest votes up vote 20 down vote accepted Use an anonymous function intId = setInterval(function(){waiting(argument)}, 10000); This creates a parameterless anonymous function which calls waiting() with arguments Or use the optional parameters of the setInterval() function: intId = setInterval(waiting, 10000, argument [,...more arguments]); Your code ( intId = setInterval(waiting(argument), 10000);) calls waiting() with argument, takes the return value, tries to treat it as a function, and sets the interval for that return value. Unless waiting() is a function which returns another function, this will fail, as you can only treat functions as functions. Numbers/strings/objects can't be typecast to a function. share|improve this answer edited Jun 22 '13 at 18:43 answered Mar 14 '13 at 13:19 Manishearth
here for a quick overview of settimeout javascript the site Help Center Detailed answers to any javascript sleep questions you might have Meta Discuss the workings and policies of this site
Javascript Delay
About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow http://stackoverflow.com/questions/15410384/javascript-setinterval-function-with-arguments Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Fix Firefox throwing error on http://stackoverflow.com/questions/15297569/fix-firefox-throwing-error-on-setinterval setInterval. [duplicate] up vote 0 down vote favorite This question already has an answer here: Pass parameters in setInterval function 14 answers Why does setInterval(fetchData(), 1000*60); work in Chrome while throw an error Firefox; I want to pass a variable into fetchdata. function fetchData(var) { ..... }; fetchData(var); //run once setInterval(fetchData(var), 1000*60); //then repeat Stack Trace: [10:26:49.764] Error: useless setInterval call (missing quotes around argument?) userController@http://localhost:8000/mainx.js:169 invoke@http://localhost:8000/lib/angular.js:2809 instantiate@http://localhost:8000/lib/angular.js:2819 @http://localhost:8000/lib/angular.js:4639 applyDirectivesToNode/nodeLinkFn/<@http://localhost:8000/lib/angular.js:4218 forEach@http://localhost:8000/lib/angular.js:117 nodeLinkFn@http://localhost:8000/lib/angular.js:4203 compositeLinkFn@http://localhost:8000/lib/angular.js:3851 publicLinkFn@http://localhost:8000/lib/angular.js:3763 bootstrap/<@http://localhost:8000/lib/angular.js:932 Scope.prototype.$eval@http://localhost:8000/lib/angular.js:7840 Scope.prototype.$apply@http://localhost:8000/lib/angular.js:7920 bootstrap/<@http://localhost:8000/lib/angular.js:930 invoke@http://localhost:8000/lib/angular.js:2802 bootstrap@http://localhost:8000/lib/angular.js:929 angularInit@http://localhost:8000/lib/angular.js:904 @http://localhost:8000/lib/angular.js:14527 p.Callbacks/k@http://localhost:8000/lib/jquery-1.8.2.min.js:2 p.Callbacks/l.fireWith@http://localhost:8000/lib/jquery-1.8.2.min.js:2 .ready@http://localhost:8000/lib/jquery-1.8.2.min.js:2 D@http://localhost:8000/lib/jquery-1.8.2.min.js:2 javascript google-chrome firefox share|improve this question asked Mar 8 '13 at 15:32 Merlin 5,1781851119 marked as duplicate by Anirudh Ramanathan, koopajah, TemplateRex, Emil, smathy Mar 8 '13 at 21:28 This question has been asked before and already has an answer. If those an
here for a quick overview of the site Help Center Detailed answers to any questions you might http://stackoverflow.com/questions/30435756/error-useless-settimeout-call-missing-quotes-around-argument have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, javascript error just like you, helping each other. Join them; it only takes a minute: Sign up Error: useless setTimeout call (missing quotes around argument?) up vote -1 down vote favorite Firefox gives a error "Error: useless setTimeout call (missing quotes around argument?)" while in Chrome its working fine. I want to make an array of addresses javascript error useless which comes from search result as a data in 'searchResultBox' div element. Now I'm passing these address one by one to Google map API to get the address. I used a setTimeout to overcome from Google's 'Over Query Limit' error. In Chrome its working fine but Firefox gives the error "Error: useless setTimeout call (missing quotes around argument?)". What should I do? var resturantids =''; var logititude =''; var latitude =''; var add =''; var rest_name =''; jQuery('.searchResultBox').each(function(){ resturantids += ''+jQuery(this).attr('data-resturantidsarr')+';'; logititude += ''+jQuery(this).attr('data-logtiresarr')+';'; latitude += ''+jQuery(this).attr('data-latiresarr')+';'; add += ''+jQuery(this).attr('data-addresses')+';'; rest_name += ''+jQuery(this).attr('data-listing-name')+';'; }); var resturantidsarr = new Array(); var logtiresarr=new Array(); var latiresarr= new Array(); var addresses = new Array(); var resturantname = new Array(); resturantidsarr = resturantids.split(";"); logtiresarr = logititude.split(";"); latiresarr = latitude.split(";"); addresses = add.split(";"); resturantname = rest_name.split(";"); var popcontentdisplay; var c=0; var b=0; var i=0; var delaytime = 10000; var nextAddress = 0; var infowindow = new google.maps.InfoWindow(); var latlng = new google.maps.LatLng(latiresarr[0], logtiresarr[0]); var mapOptions = { zoom: 12, ce