In jquery Ajax invokes the use instructions for JSON data _jquery
Source: Internet
Author: User
$.get () and $.post () the two methods are basically the same use, so just say $.post () this dongdong!
Scenario 1: $.post ("url", function); this time the returned data is not processed, so it is not JSON format!
Case 2:$.post ("url", function, "JSON"); While the returned data is specified in JSON format, it is not!
Case 3:$.post ("url", {},function); The argument passed in is empty, the returned data format is not specified, and is not JSON format!
Case 4:$.post ("url", {},function, "json"); the correct return of data in JSON format!
Important: When you want to treat the returned data as a JSON format, you must pass in the arguments (written {}) and specify the return type "JSON".
$.ajax ({
URL: "url",
DataType: "JSON",
Type: "Get"
Success:function
})
Important: To specify datatype as "JSON", the JSON format data will be available either get or post, but I recommend that you add data:{} for consistency with the above two methods.
$.getjson ("url", function)
Important: Get the way the JSON format data, is $.get () convenient writing bar!
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.