jQuery ajax 发布到 Web 服务
$(document).ready(function() {
$.ajax({ type: "POST",
url: "/getprojects.ashx",
data: "<formData client=\"\" year=\"\" categories=\"\" tags=\"\" freeText=\"\" count=\"34\" page=\"1\"></formData>",
dataType: "text/xml",
cache: false,
error: function() { alert("No data found."); },
success: function(xml) {
alert("it works");
alert($(xml).find("project")[0].attr("id"));
}
});
});
我的问题是我得到了一些数据,但我似乎无法显示它。
$(document).ready(function() {
$.ajax({ type: "POST",
url: "/getprojects.ashx",
data: "<formData client=\"\" year=\"\" categories=\"\" tags=\"\" freeText=\"\" count=\"34\" page=\"1\"></formData>",
dataType: "text/xml",
cache: false,
error: function() { alert("No data found."); },
success: function(xml) {
alert("it works");
alert($(xml).find("project")[0].attr("id"));
}
});
});
My problem is i get some data back but i can't seem to get it displayed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
dataType
应该是您收到的内容的类型,但contentType
应该是您发送的内容的 mime 类型,以下应该没问题:dataType
should be the type of what you receive butcontentType
should be the mime-type of what you are sending, the following should be ok:您的
dataType
似乎是错误的。它应该看起来像你的
data
结构也看起来很奇怪。看看 .serializeArray()。它应该是标准查询字符串 foo=bar&test=bla 等。如果
success handler
被执行,请尝试查找您的xml
变量 plain , 没有使用
.find()
或其他方式对其进行操作。还是空的?Your
dataType
seems to be wrong. It should look likeYour
data
structure also looks pretty wierd. Have a look at .serializeArray(). It should be standard query string foo=bar&test=bla etc.If the
success handler
gets executed, try to lookup yourxml
variable plain, withoutoperating on it with
.find()
or whatever. Still empty?