jquery ajax success 怎么证明 请求成功了
$.ajax({type:"POST",url:"addMessage.action",data:"m_name="+escape(m_name)+"&m_content...
$.ajax({
type: "POST",
url: "addMessage.action",
data: "m_name=" + escape(m_name) + "&m_content=" + escape(m_content) + "&b_id=" + b_id,
success: function (msg) {
//在table中新增一行
if (msg == "success")
{
$("#messagelist").append("<div class='box clearfix' id=''><div class='text'><strong><a href='#'>" + m_name + "</a></strong><p>" + m_content +"</p><div class='date'>"+m_date+"</div></div></div>");
}
}
});
这个是jsp上的javascript代码 后台用java实现的 但是我不知道怎么才能返回 msg 这个变量
public String execute()
{
HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
String m_name = request.getParameter("m_name");
String m_content = request.getParameter("m_content");
int b_id = Integer.valueOf(request.getParameter("b_id"));
MessageServices msgServices = new MessageServices();
msgServices.addMessage(b_id, m_content, m_name);
return SUCCESS;
}
这里是struts2 action的代码, 数据已经录入数据库了但是不知道怎么才能返回msg
用request.setAttribute("msg","success");行不通
在线等回答 比较急 展开
type: "POST",
url: "addMessage.action",
data: "m_name=" + escape(m_name) + "&m_content=" + escape(m_content) + "&b_id=" + b_id,
success: function (msg) {
//在table中新增一行
if (msg == "success")
{
$("#messagelist").append("<div class='box clearfix' id=''><div class='text'><strong><a href='#'>" + m_name + "</a></strong><p>" + m_content +"</p><div class='date'>"+m_date+"</div></div></div>");
}
}
});
这个是jsp上的javascript代码 后台用java实现的 但是我不知道怎么才能返回 msg 这个变量
public String execute()
{
HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
String m_name = request.getParameter("m_name");
String m_content = request.getParameter("m_content");
int b_id = Integer.valueOf(request.getParameter("b_id"));
MessageServices msgServices = new MessageServices();
msgServices.addMessage(b_id, m_content, m_name);
return SUCCESS;
}
这里是struts2 action的代码, 数据已经录入数据库了但是不知道怎么才能返回msg
用request.setAttribute("msg","success");行不通
在线等回答 比较急 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询