本文介绍了如何显示来自AJAX请求在pre标签XML响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用jQuery做一个Ajax请求进行响应的XML Web服务:
I am using jquery to make an AJAX request to a web service which responds with XML:
$.ajax({
type: "GET",
url: $uri,
dataType: "xml",
async: false,
contentType: "text/xml; charset=\"utf-8\"",
complete: function(xmlResponse) {
$("#preForXMLResponse").html(xmlResponse);
}
});
我想显示从Web服务在HTML页面内pre标签的XML响应。但是,code以上不起作用。我怎样才能改变XML响应字符串和内部pre标签显示呢?
I want to display the XML response from the web service in a HTML page inside PRE tag. But the code above does not work. How can I change the XML response to a string and display it inside PRE tag?
推荐答案
试试这个
$.ajax({
type: "GET",
url: $uri,
dataType: "xml",
async: false,
contentType: "text/xml; charset=\"utf-8\"",
success: function(xmlResponse) {
$("#preForXMLResponse").html('<pre>'+xmlResponse+'</pre>');
}
});
这篇关于如何显示来自AJAX请求在pre标签XML响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!