jquery JSP tutorial Save data Code
jquery Code
$ (). Ready (function () {
var url= "/admin/ajaxgetnewsclassfather.do";
var pars= "random=" +math.random ();
var newsclassfather= $ (' #newsClassFather ');
$.ajax ({
Url:url,
Data:pars,
Type: "POST",
Success:function (res) {
Newsclassfather.append (RES);
}
});
});
JSP code
Requestmapping ("/admin/ajaxgetnewsclassfather.do")
public void Ajaxgetnewsclassfather (Writer Writer, model model, HttpServletRequest request, httpservletresponse response )
{
Response.setcontenttype ("text/html");
Response.setcharacterencoding ("UTF-8");
String dbname= cookieutil.getdbname (request, response);
List<newsclass> newsclasslist= Newsclassjdbcservice.findbybclassid (dbname,0);
String result= ""; for (Newsclass newsclass:newsclasslist)
{
result+= "<option value= '" + newsclass.getclassid () + "' >" + newsclass.getclassname () + "</option>";
}try
{
Writer.write (result);
}catch (IOException e)
{
E.printstacktrace ();
}
}