JS SETINTERVAL code implementation page polling

Conceptual introduction

SetInterval is a function that implements timing calls, which can be called function or calculate expressions according to the specified cycle (in millisecond). The SETINTERVAL method will keep calling the function until ClearInterval is called or window being turned off.

The ID value returned by SetInterval can be used as a parameter of the ClearInterval method.

Tip: 1000 millisecond = 1 second.

Flash Usage (from Baidu Encyclopedia)

The role of the SETINTERVAL is to call functions, methods, or objects every time when playing animation. You can use this action to update variables or update time displayed from the database. The syntax format of SetInterval action is as follows:

SetInterval (Function, Interval [, Arg1, Arg2, …, …) setInterval (Object, MethodName , Interval [, Arg1, Arg2, ….. ARGN])

Implementation code (monitoring payment status)

JS SetInterval 代码实现页面轮询 $ (Document) .ready (function () {var Timer = setInterval (Function () {AJAX_WX_PAY_STATUS (TIMER)}, 3000);}); Function Ajax_WX_PAY_STATUS (TIMER) {VAR TOURL = “{: u (‘Order / Ajax_get_Pay_Status’)} “; var orderURL =” {: u (‘member / myorder’)}; if ($ (“# out_trade_no”). Val ()! = 0) {$ .post (tour, {out_trade_no: $ (“# out_trade_no”). Val ()}, function (res.status == 1) {// order status is 1 indicates that the payment is successfully // can be written in the corresponding service code, for example Payment success reminder, or directly page jump. ClearInterval (Timer); //Window.Location.href = ORDERURL; // page jump}}}, “json”);}}

  The above is the JS SETINTERVAL code to introduce you to everyone, I hope that everyone can help, if you have any questions. Leave me a message, the small package will reply to everyone in time. Thank you very much for your support for Tumi Cloud website!  
© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment