The function to be implemented here is: log in to the website by scanning the QR code of the WeChat official account with parameters. But it is obvious that if ajax requests the server continuously, this will increase the load on the server. Therefore, this example uses js's setInterval to periodically call and execute an ajax function to request data from the server, but the request is successful or the request is made a certain number of times. If it still fails, use the clearinterval function to clear the timer.
The code and comments are as follows: (The backend is implemented using thinkPHP, so the js code contains some thinkPHP syntax rules)
Related recommendations:
PHP implements WeChat PC QR code login
How to use QR code login? Summarize the usage of QR code login examples
Detailed explanation of the principle of QR code login
The above is the detailed content of Ajax polling request status. For more information, please follow other related articles on the PHP Chinese website!