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
1. Download the latest nginx docker image $ docke...
background In data warehouse modeling, the origin...
NERDTree is a file system browser for Vim. With t...
Preface Every good habit is a treasure. This arti...
Table of contents What is insert buffer? What are...
The players we see on the web pages are nothing m...
Intro Previously, our docker images were stored i...
Use JOIN instead of sub-queries MySQL supports SQ...
Create a project Create a project in WeChat Devel...
Overview For small and medium-sized projects, joi...
First, we will introduce how (1) MySQL 5.7 has a ...
This article shares the specific code of JavaScri...
method: By desc: Neither can be achieved: Method ...
This article shares a small example of adding and...
The vue project implements an upgraded version of...