Native JSHow to send a get request
var xhr = new XMLHttpRequest() xhr.open('get', '/ajax') xhr.onload = function () { console.log(xhr.responseText) } xhr.send(null) How to send a post request
var xhr = new XMLHttpRequest() xhr.open('post', '/ajax') xhr.onload = function () { console.log(xhr.responseText) } xhr.send(null) Send a get request with parameters
Send a post request with parametersvar xhr = new XMLHttpRequest No need to add anything after the request address
xhr.onload = function () { console.log( xhr.responseText ) } The parameters carried by the post method are written directly in the () after xhr.send()
var xhr = new XMLHttpRequest() xhr.open('post', '/ajax') xhr.onload = function () { console.log(xhr.responseText) } xhr.setRequestHeadr('content-type', 'application/x-www-form-urlencoded') xhr.send('key=value&key=value') var fd = new FormData(document.querySelector('form')) var xhr = new XMLHttpRequest() xhr.open('post', '/ajax') xhr.onload = function () { console.log(xhr.responseText) } xhr.send(fd) jQueryHow to use several parameters of $.getaddress
$.post several parameters, how to use them
$.ajax several parameters, how to use
JSONPHow to send jaonp request using $.ajax
$.ajax({ url: '/jsonp', data: {}, dataType: 'jsonp', jsonp: 'callback', success (res) { console.log(res) } }) SummarizeThis is the end of this article about the usage of ajax in js and jQuery. For more information about the usage of ajax in js and jQuery, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: CentOs7 64-bit MySQL 5.6.40 source code installation process
>>: Nginx defines domain name access method
A simple license plate input component (vue) for ...
The nginx configuration is as follows: Such as ht...
Find the running container id docker ps Find the ...
HTML+CSS+JS imitates win10 brightness adjustment ...
Table of contents Preface 1. Custom focus command...
See: https://www.jb51.net/article/112612.htm Chec...
Mongodb has a db.serverStatus() command, which ca...
1. Edit the PAM configuration file sudo vim /etc/...
1. DNS server concept Communication on the Intern...
The installation of mysql-5.7.17 is introduced be...
Preface Node will be used as the middle layer in ...
view: Views in MySQL have many similarities with ...
After Vmvare sets the disk size of the virtual ma...
Goal: Create a square whose side length is equal ...
WML (Wireless Markup Language). It is a markup la...