Because the company uses the technology is old, still use STRUTS1 framework, so write an Ajax and Struts1 with the use of the introductory tutorial. Below to get to the chase:
1. First introduce the way Ajax is written in JS:
$.ajax ({url: "<%=basepath%>xxx.do",//Receive AJAX request path, need to configure DataType in XML file: ' text ',//callback function return value type, text represents string Type: "POST"//request mode, post or get data:{alias: Parameter value, alias: Parameter value,...},//need to pass the parameter, no can not write data this property async:false,//default to True , False is synchronous, true represents the asynchronous Success:function (data)//callback function, and data is the return value {alert (data); } })
2. Next introduce the Struts-config.xml configuration method
<action type= "package name. Action name" path= "/xxx" scope= "Request" input= "/folder name/jsp name. jsp" > <!--type represents the action path that receives the request. Path is consistent with the Ajaxurl attribute (note that this is not written here. Do) input represents the JSP that sends the request--
At this point, Ajax has sent the request to the action, followed by the specific business to do the specific operation.
This article from "Cock silk reverse attack" blog, declined reprint!
Ajax technology and STRUTS1 framework using the Getting Started tutorial