$. Get (), $. post (), $. ajax (), $. getJSON () in Jquery, and jquery. post
This article describes $. get (), $. post (), $. ajax (), $. the usage of getJSON () is summarized in detail. For more information, see getJSON.
Details about Jquery
callback function650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7E/7D/wKiom1cCJhOxuiaCAADLnaQvY9I426.png "title=" Web.png "alt=" Wkiom1ccjhoxuiacaadlnaqvy9i426.png "/>-Send Request650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7E/7D/wKiom1cCJqqz2pd9AAEROToh3Mo703.png "title=" Web.png "alt=" Wkiom1ccjqqz2pd9aaerotoh3mo703.png "/>Writing server-side code-The server typically returns part of the data, such as a simple text650) this.width=650; "src=" Http://s2.51cto.com/wyfs
$. Get (), $. post (), $. ajax (), $. getJSON () in Jquery, and jquery. post
Details about Jquery Ajax functions:$. Get (), $. post (), $. ajax (), $. getJSON ()1, $. get (url, [data], [callback])Note: The url is the request addre
AJAX request $. post method, ajax request. post Method
The $. post method of jQuery can be used to initiate AJAX requests to the server in the form of POST. $. The
Ajax sends a Post request and ajax sends a post request.
THE post request sent by Ajax is similar to the get request. The following describes the specific instance and the JSP display page:
Then let's look at the Servlet class th
initially, because you can load the corresponding JS file according to the user's interaction, without having to load it all when the page is initialized.Copy CodeThe code is as follows:$.getscript (' Ajaxevent.js ', function () {Alert ("Scripts loaded!");Loads the Ajaxevent.js and displays a dialog prompt after a successful load.});Building a bridge for data communication: Getjson ()Getjson (Url,[data],[callback])URL (String) to send the request add
$.ajax ({Url:url,Data:data,Success:success,Datatype:datatype});
The tuning function successfully returns data passing, which will be an XML root element, a text string, a Web effects file, or a JSON object based on the MIME type of the response. It also passes the response text state.
In jquery 1.4, the successful callback function is also passed through the XMLHttpRequest object.
M
Example of Using ajax to submit POST data and ajax to submit post DataProblem description
We asynchronously submit the data in the input and checkbox of a form to the php server. After processing, the data is returned.
Position displayed after submission:
Difficulties
Use the onsubmit attribute of the from form to
var arry = eval ("(" +data+ ")");//quotation marks , the JSON string is programmed into the JSON type array, or you can add a parameter "JSON" after the $.post function to specify that the received data is a JSON type of 3 for (Var i=0;iCan also be written as follows, return is the JSON type array, do not be sad to quote, you can directly traverse.1 $.post ("Emp.do?p=getallemp", {id
()},function(data) {2 varArry =Eval("(" +data+ ")");//go to quotation marks, programming JSON string to the JSON type array, or you can add a parameter "JSON" after the $.post function to specify that the data received is a JSON-type3 for(vari=0;i){4 varOP =NewOption (arry[i].empname,arry[i).empId);5document.getElementById ("EMP"). Options.Add (OP);6 }7});Can also be written as follows, return is t
()},function(data) {2 varArry = eval ("(" +data+ ")");//go to quotation marks, programming JSON string to the JSON type array, or you can add a parameter "JSON" after the $.post function to specify that the data received is a JSON-type3 for(vari=0;i){4 varOP =NewOption (arry[i].empname,arry[i].empid);5document.getElementById ("EMP"). Options.add (OP);6 }7});Can also be written as follows, return is
() is the same as that returned by get.
1 $. Post ("EMP. do? P = getallemp ", {ID: deptid, X: math. random ()}, function (data) {2 var arry = eval ("(" + Data + ")"); // remove the quotation marks, enclose JSON strings in quotation marks to program arrays of the JSON type. the post function is followed by a parameter "JSON", which specifies that the received data is 3 for (VAR I = 0; I
You can also write
data format is of JSON type);
Three, $.ajax (Opiton)
Description: $.ajax () This function is powerful, you can do a lot of precise control of Ajax, you need to specify the relevant information to refer to$.ajax ({url: "ajax/ajax_selectpictype.aspx", Data:{full: "Fu"},type
are very supportive of this approach. For example, in PHP, $_post[' title ' can get to the value of title, $_post[' Sub '] can get a sub array.
Many times, when we use Ajax to submit data, it is also used in this way. For example, the Ajax,content-type default values for JQuery and Qwrap are "application/x-www-form-urlencoded;charset=utf-8".
②multipart/form-data
This is another common way of
JQuery Ajax instances ($. ajax _ $. post _ $. get), jquery. ajax _
Jquery is well encapsulated in asynchronous submission, and it is very troublesome to directly use AJAX. Jquery greatly simplifies our operations and does not have to worry about browser surprises.
$.
. Second, the submitted data is encoded in key1 = val1 key2 = val2, both key and val are URL transcoded. Most server languages support this method. For example, in PHP, $ _ POST ['title'] can get the title value, and $ _ POST ['sub'] can get the sub array.
This method is often used when Ajax is used to submit data. For example, for
. Second, the submitted data is encoded in key1 = val1 key2 = val2, both key and val are URL transcoded. Most server languages support this method. For example, in PHP, $ _ POST ['title'] can get the title value, and $ _ POST ['sub'] can get the sub array.
This method is often used when Ajax is used to submit data. For example, for
languages have a good support for this approach. For example, in PHP, $_post[' title ' can get the value of title, $_post[' Sub ' can get a sub array.
Most of the time, we use Ajax to submit data, which is also used in this way. For example, the Ajax,content-type default values for JQuery and Qwrap are "application/x-www-form-urlencoded;charset=utf-8".
②multipart/form-data
This is another common way to
Today saw the group inside the Netizen asked the jquery Ajax (Load,post,get,ajax) between the difference, now collated an article out, hope can help netizens, first we first look at some simple method,These are methods that encapsulate Jquery.ajax () to facilitate our use, and of course, if you are dealing with complex logic, you still need to use the Jquery.ajax
request is. The number of fields in the message body is divided into a number of similar parts of the structure, each part is started with--boundary, followed by the content description information, then enter, and finally the specific content of the field (text or binary). If you are transferring files, also include file name and file type information. The message body finally ends with a--boundary--mark.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.