Generally when we write web pages, if we use Ajax to request the server, we use JQuery and other encapsulated libraries to call it, which is relatively simple. But generally these libraries have many functions and introduce too many things that we don't need. If we need to write a simple page with a single function, there is no need to reference such a huge library file. In this article, we mainly share with you the request function function of writing Ajax in native JS, hoping to help everyone.
We can simply implement our own Ajax request function. The specific code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
Usage method: GET
1 2 3 4 5 6 7 8 9 10 11 12 |
|
There is a problem that needs to be noted here. If we want to send something like
##
1 2 3 4 5 6 7 |
|
Comprehensive summary of related methods based on ajax in jQuery
Detailed explanation of the simple implementation of AJAX paging effect
Explanation of Ajax with examples Asynchronous request technology
The above is the detailed content of Sharing examples of writing Ajax request functions using native JS. For more information, please follow other related articles on the PHP Chinese website!