The recent project, using AJAX technology in the project, encountered a strange problem: "TheJSON-formatted data returned by $.ajax cannot be executed success", as the code reads:
1 $.ajax ({
2).
3 dataType: ' JSON ',
4 ...
5 Success:function (jsondata) {
6//Do not perform success
7},
8 error:function (Error) {
9//Always execute this error
10}
11});
Why, why is this so? Checking the returned JSON string, I think the format of the JSON string should be OK, so I looked it up on the internet and found that there were really people who had the same problem as me, to find out why " because I specified datatype: ' JSON ', The JSON format requirements are very strict , at first my JSON format is written: "{result:{\" success\ ": \" true\ ", \" meg\ ": \" Success\ "}", but this can not be written, it must be changed to write: " {\ "success\": True,\ "mesg\": \ "Success\"} ", if it is bool type, then do not use quotes, the other keys/values need to be quoted." after jquery 1.4, the JSON format has been tightened, meaning that the {"key" of this format must be required: "Value ', ' key ': ' value '}; like the original {key: value, key: value} and {' key ': ' Value ', ' key ': ' Value '} This is wrong, not standard, So jquery returns the error. previously did not notice such a problem, this encounter, but also found a solution, in this record.