Home > Web Front-end > JS Tutorial > The JSON returned by $.ajax cannot be used to solve the problem of success_jquery

The JSON returned by $.ajax cannot be used to solve the problem of success_jquery

WBOY
Release: 2016-05-16 18:02:33
Original
1185 people have browsed it

I am modifying the code at night. I used the

to copy the code . The code is as follows:

$.ajax( {
..
dataType:'json',
...
success:function(json){
//Do not execute success
},
error:function (error){
//Always execute this error
}
});

Why is this like this? After searching on the Internet for a long time, I found that it was because I specified dataType:'json'. Once specified, the requirements for Json became very strict. At first, my json format was written like this: "{result:{ "success":"true","meg":"success"}}", but it doesn't work like this. You have to change it to like this: "{"success":true,"mesg":"success"}", if you say If it is a bool type, there is no need to add quotes. All other keys/values ​​need to be quoted.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template