In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about the differences between get and post methods in jquery. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Differences: 1, the data in get is sent in URL, while the data in POST is sent in the body of the body; 2, only a limited amount of data can be sent in get, while a large number of data can be sent in POST; 3, the data sent by GET method will be exposed in the URL column, while the data sent by POST method is not public and has high security.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
JQuery $.get () method
The $. Get () method requests data from the server through a HTTP GET request.
Syntax:
$.get (URL,callback)
The required URL parameters specify the URL you want to request.
The optional callback parameter is the name of the function to be executed after a successful request.
The following example uses the $.get () method to retrieve data from a file on the server:
Example
$("button") .click (function () {$.get ("demo_test.asp", function (data,status) {alert ("Data:" + data + "\ nStatus:" + status);})
JQuery $.post () method
The $.post () method requests data from the server through a HTTP POST request.
Syntax:
$.post (URL,data,callback)
The required URL parameters specify the URL you want to request.
The optional data parameter specifies the data to be sent with the request.
The optional callback parameter is the name of the function to be executed after a successful request.
The following example uses $.post () to send data along with the request:
Example
$("button") .click (function () {$.post ("demo_test_post.asp", {name: "Donald Duck", city: "www.gqgzdg.com"}, function (data,status) {alert ("Data:" + data + "\ nStatus:" + status);})
The difference between jQuery $.get () method and $.post () method
1. The amount of data sent
In GET, only a limited amount of data can be sent because the data is sent in URL.
In POST, a large amount of data can be sent because the data is sent in the body of the body.
2. Security
The data sent by the GET method is not protected because the data is exposed in the URL column, which increases the risk of vulnerabilities and hacker attacks.
The data sent by the POST method is secure because the data is not exposed in the URL column, and a variety of encoding techniques can be used in it, which makes it flexible.
3. Add to the bookmark
The result of the GET query can be added to the bookmark because it exists in the form of URL
The results of the POST query cannot be bookmarked.
4. Coding
When you use the GET method in a form, only ASCII characters are accepted in the data type.
When the form is submitted, the POST method does not bind the form data type and allows binary and ASCII characters.
5. Variable size
The variable size in the GET method is about 2000 characters.
The POST method allows up to a variable size of 8MB.
6. Caching
The data of the GET method is cacheable
The data of the POST method cannot be cached.
7. Main role
The GET method is mainly used to obtain information.
The POST method is mainly used to update data.
Thank you for reading! This is the end of this article on "what are the differences between get and post methods in jquery". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.