In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the GET and POST methods of XMLHttpRequest". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use XMLHttpRequest's GET and POST methods.
GET is simpler and faster than POST and can be used in most cases.
However, always use POST in the following situations:
Cache file is not an option (update a file or database on the server)
Send large amounts of data to the server (POST has no size limit)
Send user input (can contain unknown characters), POST is more powerful and more secure than GET
GET request
A simple GET request:
Example
Xhttp.open ("GET", "demo_get.asp", true)
Xhttp.send ()
In the above example, you might get a cached result. To avoid this, add a unique ID to URL:
Example
Xhttp.open ("GET", "demo_get.asp?t=" + Math.random (), true)
Xhttp.send ()
If you need to use the GET method to send information, add this information to URL:
Example
Xhttp.open ("GET", "demo_get2.asp?fname=Bill&lname=Gates", true)
Xhttp.send ()
POST request
A simple POST request:
Example
Xhttp.open ("POST", "demo_post.asp", true)
Xhttp.send ()
To POST data like a HTML form, add a HTTP header through setRequestHeader (). Specify the data you need to send in the send () method:
Example
Xhttp.open ("POST", "ajax_test.asp", true)
Xhttp.setRequestHeader ("Content-type", "application/x-www-form-urlencoded")
Xhttp.send ("fname=Bill&lname=Gates")
Method description
SetRequestHeader (header, value)
Add a HTTP header to the request
Header: specify the header name
Value: specify header value
At this point, I believe you have a deeper understanding of "how to use XMLHttpRequest's GET and POST methods". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.