javascript - JSON - 在 Internet Explorer 8 中不起作用

标签 javascript jquery json

我尝试了一些修复,但没有任何帮助。

在服务器端脚本中,

 $array['content'] = "test";
 echo json_encode($array);

这是在 JavaScript 中运行的。但是

 $array['content'] = "<p>test</p>";
 echo json_encode($array);

不工作。如果我添加任何 html 标签,它就不起作用。 但它们都可以在 Firefox 和 Chrome 中运行。

这是处理返回值的js。

 function showResponse(responseText)  {
     $('.form_result').html(responseText.formData);
      alert(responseText.formData);
 }

 function submitButton1() {

    var options = {
        beforeSubmit:  showRequest,  // pre-submit callback
        success:       showResponse,  // post-submit callback
        dataType: 'json',
        cache: false
    };

    // bind form using 'ajaxForm'
    $('#form').ajaxSubmit(options);
 }

     header("Cache-Control: no-cache, must-revalidate");
header("Expires: 0"); 

在 php 文件中添加以上两行。

 <meta http-equiv="X-UA-Compatible" content="IE=8" />

在处理js的html文件中添加了上述内容。还是没用。

可能是什么问题? 此外,我在 IE 中没有看到任何错误或警告。

最佳答案

Internet Explorer 8 不支持 jQuery 使用的 XMLHttpRequest 对象中的 CORS ie8使用XDomainRequest对象

jQuery 默认不支持 XDomainRequest。

检查这个An update is available for the native JSON feature in Internet Explorer 8

关于javascript - JSON - 在 Internet Explorer 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12976801/

相关文章:

javascript - 如何解析 key :value pair on JSON-like string with RegEx on JavaScript?

javascript - 查询。从数字类型输入中获取输入值。比较时它返回真,我不知道为什么

javascript - 如何使用js在下载的文本文件中添加换行符

android - java.lang.IllegalArgumentException : Parameter specified as non-null is null while parsing JSON to kotlin Data class 异常

java - 如何在java中创建嵌套的json

jquery - 如何自动设置光滑轮播的高度

javascript - 为什么必须用括号括起要在其上调用 toFixed 的数字?

java - 如何动态构造和设置 dijit.form.select 小部件的选项?

javascript - 支持SVG引擎的浏览器和版本列表

javascript - 将光标放在 IE 中未显示但在 FireFox 中显示的链接上