用ajax如何从action那里拿数据?
public String ajaxSubmit(){
try{
Integer tId = this.TId;
String tName = this.TName;
System.out.println(tId+":"+tName);
PrintWriter p = null;
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text;charset=utf-8");
SpsTitle spsTitle = createTitleService.findByTid(tId);
spsTitle.setTName(tName);
createTitleService.update(spsTitle);
p = response.getWriter();
JSONObject jsonObject = JSONObject.fromObject(spsTitle);
p.print(jsonObject);
// p.print(spsTitle.getTName());
p.flush();
p.close();
}catch(Exception e){
e.printStackTrace();
}
return null;
}
$.ajax({type:'POST',
url:'createTitleAction!ajaxSubmit',
data:{TId:id ,TName:tName}, // 数据
success:function(data){
alert(data);//为什么我拿不到数据? 要怎么拿?
},
error:function(err){
alert("失败");
}})

浙公网安备 33010602011771号