jQuery Ajax响应“未定义"使用Internet Explorer [英] jquery Ajax response "undefined" with Internet Explorer

查看:108
本文介绍了jQuery Ajax响应“未定义"使用Internet Explorer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了jquery ajax请求的情况.

I've got a situation with jquery ajax requests.

<script type="text/javascript">
$(document).ready(function() {
    $.ajax({
        type: "POST",
        async: false,
        cache: false, 
        url: "/ajax/script.php",
        data: { display: 'user', user_id: '1'}
    }).done(function( msg ) {
        if (msg !== "") {
            alert(msg);
        }
    });
});
</script>

使用Chrome& Firefox我有由脚本/ajax/script.php生成的html代码 使用IE8(我没有尝试过6、7和9+),我有Undefined

With Chrome & Firefox I've html code generate by the script /ajax/script.php With IE8 (I've not tried with 6, 7 and 9+) I have Undefined

有人知道该如何解决吗?

Do someone knows how to fix that?

我正在使用jquery 1.7.2

I'm using jquery 1.7.2

推荐答案

在IE8中,返回application/json; charset=utf8的MIMEType对我造成了相同的行为.将其更改为application/json;可使IE8神奇地开始运行.

Returning the MIMEType of application/json; charset=utf8 caused this same behavior for me in IE8. Changing it to application/json; made IE8 magically start functioning.

这篇关于jQuery Ajax响应“未定义"使用Internet Explorer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆