JQUERY成功返回
我有一个 jQuery UI 框,它将数据传递到我的 servlet,如果 servlet 请求失败,我有这个设置;
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.getWriter().write("<valid>false</valid>");
我如何从成功函数中访问它? (或者这是错误的?)
这是我的 jQuery 代码:
$.ajax({
//this is the servlet file that processes the data and send mail
url: "Register",
//GET method is used
type: "POST",
//pass the data
data: data,
//Do not cache the page
cache: false,
//success
success: function (response) {
//$( "#message" ).append( response );
}
I have a jQuery UI box that passes data onto my servlet, if the servlet fails the request, i have this set;
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.getWriter().write("<valid>false</valid>");
How can I access this from the success function? (or is that wrong?)
Here is my jQuery code:
$.ajax({
//this is the servlet file that processes the data and send mail
url: "Register",
//GET method is used
type: "POST",
//pass the data
data: data,
//Do not cache the page
cache: false,
//success
success: function (response) {
//$( "#message" ).append( response );
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需检查 XML 响应的内容即可。
然而,我更喜欢 JSON 而不是 XML,在 jQuery 中遍历它更容易、更直观。
Just check the content of the XML response.
I'd however prefer JSON over XML, it's easier and more intuitive to traverse it in jQuery.