我正在尝试使用此jquery代码将Accept HTTP标头设置为"text/xml":
$.ajax({
beforeSend: function(req) {
req.setRequestHeader("Accept", "text/xml");
},
type: "GET",
url: "[proper url]",
contentType: "text/plain; charset=utf-8",
dataType: ($.browser.msie) ? "text" : "xml",
username: '---',
password: '-------',
success: function(data) {
var xml;
if (typeof data == "string") {
alert("Data is string:" + data);
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(data);
} else {
xml = data;
alert("Data is not string:" + $(xml).text());
}
// Returned data available in object "xml"
//alert("Status is: " + xml.statusText);
$("#ingest_history").html($(xml).text());
}
});
Run Code Online (Sandbox Code Playgroud)
在Firefox中它很棒. …