不要在IE xml / jquery中获取内容

时间:2010-10-22 10:38:18

标签: jquery xml internet-explorer

麻烦的是,除了IE之外,所有浏览器都能正常运行。我从xml获取内容并且我能够打印它,但在IE上它给出了空的。

经过一些谷歌搜索后,问题可能是这个标题的宽度(“content-type:application / xml; charset = utf-8”); 我想把它放在哪里?在xml文件开始或?

感谢。

2 个答案:

答案 0 :(得分:0)

在Javascript中:

  var req = new XMLHttpRequest();
  req.open("POST", "http://www.example.com/", true);
  req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

查看JQuery XHR文档以获取类似的API。

答案 1 :(得分:0)

$.ajax({
    'url': '',
    'beforeSend': function(xhr) {
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    }
});

还尝试禁用即用PHP缓存

header(“Cache-Control:no-cache,must-revalidate”); header(“Expires:Sat,26 Jul 1997 05:00:00 GMT”); header(“Pragma:no-cache”);