Using SPRINGMVC to implement Ajax, there are a lot of problems, recording several more common:
1: Not in the Controller class, the corresponding Ajax method to add @responsebody, this must be added, otherwise the return value to the page, JS gets always null;
2:controller class, the return value, can not be jsonobject, this I look at the information on the Internet, as if SPRINGMVC do not support the reason, with struts2 is possible, in order to insure, return JSON format string can;
3: After the page gets the Ajax return value, the processing can be as follows:
$.post (url,data,function (Result) {
var map = eval ("(" +result+ ")");
for (var key in map) {
alert (key+ '---' +map[key] );
}})
The return value inside my class is the map type to JSON, and then to the string type, using JS to accept, parsing can be.
SPRINGMVC implementation of AJAX issues