1, the front desk using jquery ajax request
$.ajax ({
URL: "R_getroleper.action",
dataType: ' JSON ',
data: {userId: "1"},//Request additional parameters, with JSON object
Method: ' POST ',
success:function (data) {
$.messager.alert (' message ', Data.add, ');
This is used in the Easyui format
},}
);
2, the action inside the use of Response.getwriter () PrintWriter object to print data to the foreground
Public PrintWriter out () throws ioexception{
HttpServletResponse response=servletactioncontext.getresponse ();
Response.setcontenttype ("text/html");
Response.setcontenttype ("Text/plain; Charset=utf-8 ");
PrintWriter out= response.getwriter ();
return out;
}
jsonobject permision = new Jsonobject ();
Permision.put ("Add", 0);
Permision.put ("delete", 0);
Permision.put ("Update", 0);
Out (). Print (permision.tostring ());
Out (). Flush ();
Out (). Close ();
Note that the Permision object is printed to the foreground is a JSON string, and in the first step of the AJAX request the success returns the data to the Permision object, So using Data.add is a value that you can get to the JSON object, if the data in the background is not JSON, but the list object uses data[0] so you can get it, but it's recommended son delivery.
The above is a small set to introduce the jquery Ajax request background data and reception in the foreground, I hope to help you, if you have any questions welcome to my message, small series will promptly reply to everyone!