这里我写了对ajax响应对象的响应
protected void writeAjaxResponse(HttpServletRequest req
,HttpServletResponse resp,String result){
PrintWriter writer = null;
try {
writer = resp.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
writer.println(result);
return;
}
后来我打电话
writeAjaxResponse(req, resp, "<p style=color:red>Error occured recording
your feedback!</p>");
在jQuery中
$.ajax({
type: 'POST',
url: 'savefeedback',
data: 'feedbacker='+feedbacker+'feedbackeremail=
'+feedbackeremail+'feedbacker='+feedbackermsg,
success:function(data){
alert(data); //here is the pin point
}
});
但在警觉中我得到
[object XMLDocument]
编辑:
这是我的servletdoPost()
方法
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String feedbacker = req.getParameter("feedbacker");
String feedbackeremail = req.getParameter("feedbackeremail");
String feedbackermsg = req.getParameter("feedbackermsg");
boolean saveFeedback = MailSenderServlet.
saveFeedback(req, resp, feedbackeremail, "",
feedbackermsg, feedbacker, feedbackeremail);
if(saveFeedback){
writeAjaxResponse(req, resp, "Feedback received succesfully!");
}else{
writeAjaxResponse(req, resp, "Error occured !");
}
}
但我期待我的回复信息。
如果我错过了什么,请告诉我。
请帮忙!!!!