In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces what is the difference between AJAX using get and post mode, it has a certain reference value, interested friends can refer to it, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
The specific analysis is as follows:
If it is a request in get mode, the passed parameters are sent to the server through the URL address
If it is a request in post mode, the passing parameters are sent to the server through the send () method (and the request header must be set)
The code for the post mode is as follows:
An example that demonstrates the difference between get mode and post mode:
Client:
Code example:
GET VS. POSTvar xmlHttp;function createXMLHttpRequest () {if (window.ActiveXObject) xmlHttp = new ActiveXObject ("Microsoft.XMLHttp"); else if (window.XMLHttpRequest) xmlHttp = new XMLHttpRequest ();} function createQueryString () {var firstName= document.getElementById ("firstName"). Value; var birthday= document.getElementById ("birthday"). Value; var queryString = "firstName=" + firstName + "& birthday=" + birthday; return encodeURI (encodeURI (queryString)) / / twice coding to solve the problem of Chinese garbled code} / / GET mode function doRequestUsingGET () {createXMLHttpRequest (); var queryString = "9-3.aspx?"; queryString + = createQueryString () + "& timestamp=" + new Date (). GetTime (); xmlHttp.onreadystatechange = handleStateChange; xmlHttp.open ("GET", queryString); xmlHttp.send (null);} / / POST mode function doRequestUsingPOST () {createXMLHttpRequest (); var url = "9-3.aspxtimestamp =" + new Date (). GetTime () Var queryString = createQueryString (); xmlHttp.open ("POST", url); xmlHttp.onreadystatechange = handleStateChange; xmlHttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded"); xmlHttp.send (queryString);} function handleStateChange () {if (xmlHttp.readyState = = 4 & & xmlHttp.status = = 200) {var responseDiv = document.getElementById ("serverResponse"); responseDiv [XSS _ clean] = decodeURI (xmlHttp.responseText); / / Decode}} enter name and birthday
Server side
Code example:
Usually when there is not much data and is not sensitive, requests using get mode
When the amount of data is large, or when the data is sensitive, the request uses post mode.
Thank you for reading this article carefully. I hope the article "what is the difference between AJAX using get and post mode" shared by the editor will be helpful to you. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you 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.