如何在成功事件处理程序中将XML文档的内容输出到$(this)?jQuery:如何将XML文档的内容输出到节点?
var useJson = false;
var acceptHeader;
if (useJson) {
acceptHeader = "application/json";
} else {
acceptHeader = "text/xml"
}
$.ajax({
url: '<%= Url.Action("GetAllCategories") %>',
beforeSend: function (req) {
req.setRequestHeader("Accept", acceptHeader);
},
type: 'POST',
accepts: "application/json",
context: $("#divGetAllCategories"),
contentType: 'application/json; charset=utf-8',
error: function (data) {
$("html").html(data.responseText);
},
success: function (data) {
if (useJson) {
$(this).text(JSON.stringify(data));
}
else {
//How do i insert xml data into $(this) as text?
}
}
});
感谢您的帮助! :) – burnt1ce 2011-04-21 14:44:48