http method of Get compare post
GET: Request data from the specified resource, POST: Submits the data to be processed to the specified resource
Get method:
Note that the query string (name/value pair) is sent in the URL of the GET request:
/test/demo_form.asp?name1=value1&name2=value2
Some additional comments about the GET request:
-
- Get requests can be cached
- GET requests remain in browser history
- Get requests can be bookmark-Favorites
- GET requests should not be used when handling sensitive data
- Get request has a length limit
- GET requests should only be used to retrieve data
Post method:
corresponding to the
1 will not be cached, 2 will not remain in the browsing record, 3 cannot bookmark, and 4 data length is unlimited.
Example:
$ ("button"). Click (function() { $.post ("demo_test_post.asp", { name:" Donald Duck ", City :" Duckburg " }, function(data,status) { Alert ("data:" + Data + "\nstatus:" + status); } );
You can find that the post is a parameter and the request is sent together to the parameter Yes (URL) request is data name and city
This ASP code is as follows
<%Dim fname,cityfname=request.form ("name")City =request.form ("City") Response.Write ("Dear" & fname & "." ) Response.Write ("Hope you live ' Well ' & City &". " )%>
About using AJAX to send a value to the background: JSP page code
User name:<inputtype= "text"name= "User" id= "user" />Email:<inputtype= "text"ID= "Email"name= "Email" /> <DivID= "Showuser"></Div> <inputtype= "button"value= "Get Value"ID= "Btnget"onclick= "GetValue ()" />
In JS, the code is as follows
function GetValue () { $.ajax ({ type:"POST", URL:"loaduser.action", data:{ user:$ (' #user '). Val (), email:$ (' #email '). Val () }, function (response, status, XHR) { console.log (response); $ (' #showuser '). html (response[0].content); } );};
Note Use user:$ (' #user '). Val (), get to the value where ' #user ', the function is id= "user" instead of name= "user" (try to know). If the background action can be directly in the background with the same name, using the Getset method to get the value.
Console.log (response) is the output of the returned value in the browser's console.
About radio button and select Collection how to get the corresponding value in Ajax JS
<inputID= "Usersex"name= "Usersex"type= "Radio"value= "Male"checked= "Checked" /> male<inputID= "Usersex"name= "Usersex"type= "Radio"value= "female" /> female<inputID= "Usersex"name= "Usersex"type= "Radio"value= "Confidential" /> Confidentiality<S:selectList= "Listnums"ListValue= "Numname"ListKey= "NumId"name= "NumId"ID= "NumId"Headerkey= "Ol"Headervalue= "Please select"value= "Bean.numid"></S:select>
The following JS is the method of value, have been used by their own, (about radio I think it is quite complicated, I do not know someone to provide more simple not)
var sex=document.getelementsbyname ("Usersex"); // can not Getelementbyid,byid and only reading the first value of the group var for (var i = 0; i < sex.length; i++) { if(sex[i].checked) = sex[i].value;} // Sexvalue is the value you need. var numId = document.getElementById (' numId '). Value; // Select selection box More simple this sentence is OK.