相关疑难解决方法(0)

无法使用jQuery正确设置Accept HTTP标头

我正在尝试使用此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中它很棒. …

ajax jquery internet-explorer header http

73
推荐指数
4
解决办法
9万
查看次数

标签 统计

ajax ×1

header ×1

http ×1

internet-explorer ×1

jquery ×1