日期:2014-05-17  浏览次数:20594 次

java ajax传值问题
Action取得全部的方法
public String getAllList() {

Long userId = ContextUtil.getCurrentUserId();
String msg = alertRecordService.getAll(userId, 1);
return msg;
}

页面加载的时候调用该方法
$(document).ready(function(){
$.ajax({
type:"GET",
url:"<%=basePath%>/alert/getAllListAlertRecord.do",
success : function(msg) {
alert(msg);
$(function() {
$.messageBox({
//timeout : 5000,
ms : "您有新的消息,请及时查看"
})
})
}
})
})



我的问题是: 这块怎么拿action当中返回的值
 因为我想将其返回的值传给另外的一个js窗体显示的方法

------解决方案--------------------
aciton不要返回值,改成这样:

public String getAllList() {

Long userId = ContextUtil.getCurrentUserId();
String msg = alertRecordService.getAll(userId, 1);
response.getWriter().print(msg);//若msg为你要的返回值,也就是你页面要显示的
return null; //return NONE;应该也可以不过我没试过
}