Home >Web Front-end >JS Tutorial >How to implement multiple ajax requests
This time I will show you how to implement multiple ajax requests. What are the precautions for implementing multiple ajax requests? The following is a practical case, let's take a look.
When we use ajax to request data, we may encounter the possibility of multiple triggers with one click.
(For example: ajax's onreadystatechange event will be triggered multiple times; this is because onreadystatechange is an event handle.
Its value (state_Change) is a The name of the function, this function will be triggered when the state of the XMLHttpRequest object changes.
The state changes from 0 (uninitialized) to 4 (complete) only when the state is 4. We just execute the code. "
This function will be triggered every time the state of the XMLHttpRequest object changes.
It will be triggered 4 times in total, from 0 to 4.) [PS: Of course here The examples cited in are not completely consistent with the problems encountered at work] At this time, we need a method that can terminate the program.
exit and abort are both used to terminate the program. function, let’s talk about the difference between the two.
##exit will do some release work: Release all . Static global objects, cache, turn off all I/O channels, and then terminate the program. If a function is registered through atexit, the registered function will be called. However, if the atexit function throws an exception, Terminate will be called directly.
##abort: The terminate program immediately, without any cleanup work I believe you have mastered the method after reading the case in this article. , for more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How to select the date range for the DatePicker attribute of Bootstrap
##How to use AJAX to implement waterfall flow
The above is the detailed content of How to implement multiple ajax requests. For more information, please follow other related articles on the PHP Chinese website!