问题
I have:
<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>
This seems to work on every browser except IE, why is that?
Am I doing the right thing? the only thing which I need is to access the returned data like response.status
and response.reason
.
Thanks for helping
回答1:
This is a mentioned IE10 bug that can be fixed by adding
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
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.
来源:https://stackoverflow.com/questions/22007423/treat-callback-response-in-ajax-as-json