作为JSON在$就请客回调响应() [英] Treat callback response in $.ajax() as JSON

查看:114
本文介绍了作为JSON在$就请客回调响应()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:

<script>
    $('#email').on('blur', function(){
        email = $(tihs).val();
        $.ajax({
            type: "POST",
            url: "ajax.php",
            data: {
                'email': email,
                'job': 'check',
            },
            dataType: "JSON",
            success: function (response) {
                // the response from PHP is smth like:
                // {"status":"failed","reason":"email_not_validated"}
                // now I want to:
                if(response.status == 'success'){

                }else{

                }
            }   
        })
    });
</script>

这似乎工作在每一个浏览器的除了IE浏览器,这是为什么?

This seems to work on every browser except IE, why is that?

我做了正确的事情?这是我唯一需要的是访问返回的数据,如 response.status response.reason

Am I doing the right thing? the only thing which I need is to access the returned data like response.status and response.reason .

感谢您帮助

推荐答案

这是一个提到 IE10错误可以通过添加一>

This is a mentioned IE10 bug that can be fixed by adding

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

&LT; HEAD&GT; 。注意在&LT; HEAD&GT; 不应该有与另一个meta标签的X UA兼容为previous人会被覆盖。

in the <head>. Note in a <head> there should not be another meta tags with X-UA-Compatible as the previous one will be overridden.

这篇关于作为JSON在$就请客回调响应()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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