Js:
function ResponseJson1 () {
var array=[1001,1002];
var str= "";
Get Table Object
$.ajax ({
Type: ' Post ',
URL: ' ${pagecontext.request.contextpath}/testlist.action ',
The request is key/value there is no need to specify ContentType, because the default is the Key/value type
ContentType: ' Application/json;charset=utf-8 ',
Data format is JSON string, commodity information
Data: ' array= ' +array+ ',
Success:function (data) {//return JSON results
Window.alert ("Mmmmm" +data[0].name);
for (Var i=0;i<data.length;i++)
{
str+= "<tr><td>" +data[i].name+ "</td><td>" +data[i].name+ "</td></tr>";
}
$ ("#L_search_R_dh2_3_3"). Append (str);
window.location.href= "url";
}
});
}
Background:
Request Key/value, Output JSON
@RequestMapping ("/testlist")
Public @ResponseBody list<items> testlist (int[] array) {
List<items> list=new arraylist<items> ();
@ResponseBody turn Itemscustom into JSON output
for (int i=0;i<array.length;i++) {
System.out.println ("I am key value" +array[i]);
}
Items items2=new items ();
for (int i=0; i<15;i++)
{
Items2.setname ("AAA" +i);
List.add (ITEMS2);
}
return list;
}
Ajax pass-through methods are arrays