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
Table of contents 1. What is grub encryption 2. g...
Table of contents 1. Install and create an instan...
Why do we need to summarize the browser compatibi...
In the process of web project development, we oft...
Setting the font for the entire site has always b...
Preface At work, we often need to operate in a Li...
Scenario: The data in a table needs to be synchro...
Table of contents Object parameters using destruc...
1. Two types of DMA mapping 1.1. Consistent DMA m...
Table of contents 1. Theory SERIALIZABLE REPEATAB...
When we do CSS web page layout, we all know that i...
Table of contents 1. How to locate and optimize s...
cause The reason for writing this blog is that I ...
System environment: Redis version: 6.0.8 Docker v...
<table id=" <%=var1%>">, the...