Home > Web Front-end > JS Tutorial > body text

How to implement multiple ajax requests

php中世界最好的语言
Release: 2018-04-03 13:47:10
Original
2178 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template