日期:2014-05-16  浏览次数:20683 次

用ajax如何拿到action里面的值??
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(tName);
// 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.tName);//为什么这里拿不到值?
},
error:function(err){
alert("失败");
}})