我有:
<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 之外的所有浏览器,这是为什么?
我做的事情正确吗?我唯一需要的是访问返回的数据,例如 response.status
和 response.reason
。
感谢您的帮助
最佳答案
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
在 <head>
。注意<head>
不应有其他带有 X-UA-Compatible
的元标记因为前一个将被覆盖。
关于javascript - 将 $.ajax() 中的回调响应视为 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22007423/