我尝试了一些修复,但没有任何帮助。
在服务器端脚本中,
$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/