When using Ajax in jquery to get pure data, what if datatype is write in JSON background Java?
1 $.ajax ({2URL: "********",3Successfunction(data) {4 alert (data.data);5 },6Errorfunction() {7Alert ("Error");8 },9DataType: "JSON",TenType: "POST" One});
The great God, please detour.
This is a problem in setting up the environment for testing, write a JSON directly in Response.getwriter () and then alert out at the foreground.
For example, a JSON string {"Data": "Hello"} , because this write () is placed in a string, so the JSON is written inside to add the escape character "\", the manual implementation of ToString (), that is, write
Response.getwriter (). Write ("{\" data\ ": \" hello\ "}");
If it is a simple JSON string can be used, if it is dynamic complex, or old practical method.
Rookie one, the great God do not ridicule.
The writing of background write when datatype is JSON in $.ajax