作为JSON在$就请客回调响应()回调、JSON

2023-09-10 20:35:29 作者:烟燎

我有:

<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.