SetTimeout () recursive call without quotation marks error solution _ javascript skills

Source: Internet
Author: User
If setTimeout () is used to implement recursive calling, an error will occur if the first parameter is not enclosed in quotation marks. We will share with you how to solve the problem by using setTimeout () to implement recursive calling, if the first parameter is not enclosed in quotation marks, Firefox prompts setTimeout (): uselesssetTimeout call (missing quotes around argument ?) If the quotation marks are added, Firefox will prompt the undefined function.

Function refreshNum () {$. ajax ({type: "POST", url: "ajax/RefreshNum. ashx ", async: false, data :{}, success: function (data) {varnumArry = data. split (','); $. each ($ (". rush_left "), function (n) {detail (this).children().eq(0).html (numArry [n]) ;}); setTimeout (function () {refreshNum () ;}, 3000 ); // setTimeout ("refreshNum", 3000); // This will result in an error. For setTimeout () function parameters, do not use simple function calls, but use anonymous functions! Why don't you know?});} refreshNum ();
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.