SSH implementation of Ajax

I am the jump get method of jQuery to user name existence judgment in action action! This method returns a Boolean value. . And then return to action is the "success"! I < struts; result name= "success" > /index.jsp</result> my page callback function to get is the whole page to let me the values in action through the callback returns to the page! Seeking guidance!

Started by Shelley at November 08, 2016 - 8:00 AM

Brother AJAX is not in the PHP language, what is what, in java. Because it runs in the client environment (is parsed into HTML). It is requested that URL may have difference

Posted by Sean at November 14, 2016 - 8:55 AM

Server write
                        HttpServletResponse  response = ServletActionContext.getResponse();
			response.setContentType("text/html");
			response.setCharacterEncoding("UTF-8");
			response.getWriter().write("{articleCommentId:"+act.getId()+",creationDate:'"+creationDateTo+"',articleCommentContent:'"+act.getContent().replace('\'', '\"')+"'}");
   


Write this on the client side, access to JSON data
$.ajax({
		url : "/blog/blog.action",
		type : "post",
		data : {
			articleId : articleId,
			articleCommentContent : content,
			"method:saveArticleComment" : "www"
		},
		success : function(data) {
                   alert(data);
		}
	});

Posted by Angelina at November 27, 2016 - 9:34 AM

Mainly need to use the JSPWiter object, of course, methods in the action function returns no parameter void

Posted by Angelina at November 28, 2016 - 9:48 AM

I don't know you what, anyway, to action if you want to in the callback function function(data){

}To get the results, then action must format conversion to return.
// JSON conversion
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("UTF-8");

JSONObject jsonObject = new JSONObject();
String json = jsonObject.toString();
jsonObject.accumulate("map3", map3);
PrintWriter writer = null;
try {
writer = response.getWriter();
writer.write(json);

writer.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (writer != null) {
writer.close();
}
}
return SUCCESS} The case, see for yourself

Posted by Gilbert at December 09, 2016 - 10:03 AM

The 2 floor to say.

Posted by Dunn at December 11, 2016 - 10:16 AM

The 2 floor to say.

Posted by Dunn at December 20, 2016 - 10:54 AM