1

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

behz4d
  • 1,819
  • 5
  • 35
  • 59

1 Answers1

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.

Yang
  • 8,580
  • 8
  • 33
  • 58
  • is it gonna work also on OLD IEs? I'm using jQuery 1.11 with Bootstrap 3 – behz4d Feb 25 '14 at 07:42
  • sure, it will work even with IE6 including any *stable* version of jquery – Yang Feb 25 '14 at 07:43
  • No it won't work as far as trailing comma is concerned, you can test it for sure. – Jai Feb 25 '14 at 07:44
  • @Jai I believe you're wrong, trailing commas never cause errors, and I'm just seeing it working WITH the comma... . – behz4d Feb 25 '14 at 07:45
  • @behz4d He's right - that misleading comma could cause syntax error in outdated browsers. So the best thing here you can do is remove it after `'job': 'check',`. Anyway you have nothing to loose. – Yang Feb 25 '14 at 07:48
  • in IE i seen this kind of issues because of commas – Prashobh Feb 25 '14 at 07:48
  • @djay still the 'job' is not being sent in IE 10 :-(, I have also removed the comma – behz4d Feb 25 '14 at 07:50
  • @behz4d Try `print_r($_POST)` (for testing purposes) in your php script when running IE10. What does it return? – Yang Feb 25 '14 at 07:52
  • @djay how should be the PHP side with this? I'm doing with `if(isset($_POST['job'])){..}else{ echo "nojob"; }` – behz4d Feb 25 '14 at 07:53
  • with print_r($_POST): in Mozilla I get: `Array ( [email] => dsadsaddasd [job] => check )` – behz4d Feb 25 '14 at 07:55
  • in IE I get an empty array Array () – behz4d Feb 25 '14 at 07:55
  • @behz4d Well seems like a solution to this would be adding `` in the `` – Yang Feb 25 '14 at 08:02
  • @behz4d As for an explanation, take a look at this: http://code.gishan.net/code/solution-to-ie10-ajax-problem/ – Yang Feb 25 '14 at 08:03
  • WTF IE's doing alive? – behz4d Feb 25 '14 at 08:07
  • @djay I had ``, I removed it and placed with ``, now it's working fine, what was the thing I removed? `content="IE=edge"` – behz4d Feb 25 '14 at 08:17
  • @behz4d Yeah exactly. This is because it was overridden. Look, you had ` – Yang Feb 25 '14 at 08:18
  • @behz4d An explanation of `IE=edge` is here: http://stackoverflow.com/a/14611323/1208233 – Yang Feb 25 '14 at 08:20
  • Yup I read that earlier, but since I'm on Bootstrap 3, removing that and replacing it with the new one is gonna work for responsiveness? and please update your answer so I could accept it. ty – behz4d Feb 25 '14 at 08:24
  • @behz4d Since the tags/values that agents do not understand will be ignored, I'd assume that this should work for responsiveness too. – Yang Feb 25 '14 at 08:42
  • @djay mistyped, ty anyway – behz4d Feb 25 '14 at 08:48