Home  >  Article  >  Web Front-end  >  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
WBOYOriginal
2016-05-16 18:02:331116browse

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.
Statement:
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