$. Get () and $. post () methods are basically the same, so only $. post () is used!
Scenario 1: $. post ("url", function); The returned data is not processed, so it is not in json format!
Scenario 2: $. post ("url", function, "json"); although the returned data is specified in json format, it is not actually!
Case 3: $. post ("url", {}, function); the input parameter is null and the returned data format is not specified, so it is not in json format!
Scenario 4: $. post ("url", {}, function, "json"); The json format data is returned correctly!
Key point: to process the returned data in json format, you must input a parameter (the parameter is written as {} if it is null) and specify the return type as "json "!
$. Ajax ({
Url: "url ",
DataType: "json ",
Type: "get"
Success: function
})
Key Point: To specify dataType as "json", both get and post methods will get json data. However, we recommend that you add data to the above two methods to ensure consistency:.
$. GetJSON ("url", function)
Key Point: get data in json format. It is convenient to write $. get!
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.