-
Java returns an object, DataType: "Text";
Java returns a JSON string, DataType: "JSON"; Page Json.parse () parsing, parsing JSON strings into JSON objects
2,
ContentType: "Application/json",//format sent to the server
DataType: "Text",//server to the format of the page, if the JSON format with Json.parse () parsing, if it is an object on the text
3.
$.ajax ({
URL: "/test.do",
Data: {' x ': ' 001 '},
Async:false,
Type: "GET",
/* DataType: "Text", */
ContentType: "Application/json",
DataType: "JSON",
Success:function (data) {
Alert (data[' count ');
}
});
@RequestMapping (value = "Test.do")
@ResponseBody
Public map<string, object> test (httpservletrequest request, String x) {
Map<string, object> m = new hashmap<string, object> ();
M.put ("Count", 0);
return m;
}
4.
$.ajax ({
URL: "/test1.do",
data:{},
Async:false,
Type: "GET",
DataType: "JSON",
Success:function (data) {
var dataobj = json.parse (data);
alert (dataobj.1);
}
});
@RequestMapping (value = "Test1.do")
@ResponseBody
Public String Checkinfo (httpservletrequest request,httpservletresponse response) {
map<string, boolean> checkmap = new hashmap<string, boolean> ();
Checkmap.put ("1", false);
Checkmap.put ("2", true);
Jsonarray json = Jsonarray.fromobject (CHECKMAP);
return json.tostring ();
}
Some summary of the call between Java and Ajax