JSON-在Internet Explorer 8中无法使用 [英] JSON - Not working in Internet Explorer 8
问题描述
我尝试了一些修复工作,没有任何帮助.
I tried few thing to fix, Nothing helped.
在服务器端脚本中,
$array['content'] = "test";
echo json_encode($array);
这在javascript中工作.但是
This is working in javascript. But
$array['content'] = "<p>test</p>";
echo json_encode($array);
不起作用.如果我添加任何html标记,则无法正常工作. 但是他们都使用Firefox和Chrome.
Not working. If i add any html tag, it is not working. But they all are working in firefox and chrome.
这是处理返回值的js.
This is the js handling the return value.
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文件中添加了以上两行.
Added the above two lines in php file.
<meta http-equiv="X-UA-Compatible" content="IE=8" />
在处理js的html文件中添加了上述内容.还是没用.
Added the above in html file which handling the js. Still no use.
可能是什么问题? 此外,我在IE中看不到任何错误或警告.
What could be the problem? additionally, i dont see any error or warning in IE.
推荐答案
Internet Explorer 8在jQuery使用的XMLHttpRequest对象中不支持CORS. ie8使用XDomainRequest对象
Internet Explorer 8 doesn't support CORS in the XMLHttpRequest object which jQuery is using ie8 uses XDomainRequest object
jQuery默认不支持XDomainRequest.
jQuery doesn't support XDomainRequest by default.
选中此更新可用于Internet Explorer 8中的本机JSON功能
这篇关于JSON-在Internet Explorer 8中无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!