jquery jsp教程保存数据代码
jquery代码
$().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代码
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();
}
}
首页 1 2 末页