Please enter http://blog.csdn.net/hzz780/article/details/42124607 using PHP
In other words, last week, the page local JSON data debugging handed to the program, he told me to always return the error, not executed. I went to the interview with my girlfriend 5 last week and didn't come back to deal with it. Today a deal, found the original problem is so, before writing a http://blog.csdn.net/hzz780/article/details/26611431 "pure JS Ajax readystate do not return 4,jquery $." Ajax implementation ERROR,STATUS200 and the data can be displayed is further improved and the problem is clear.
Problem, always return error, I modified the setcontenttype, and did not return to success as scheduled, began to find other reasons.
Run to see the $.ajax of jquery. Use documentation
When you debug with chrome, the data returned is in this form
<span style= "White-space:pre" > </span>{' Error ': 0, ' name ': ' Huangzongzhe '}
And the standard JSON is going to be like this
<span style= "White-space:pre" > </span>{"error": 0, "name": "Huangzongzhe"}To use double quotes instead of single quotes, anything that is wrong will cause $.ajax to throw an error.
Sure enough, in Java, all of the ' convert to ', $.ajax return to the success we want to say Rtnjson.replace ("'", "\"), and then output JSON, of course, directly into the stringbuffer inside the time with "\ "Just fine."
OK, there is a problem, we can read more documents. It's still amazing.