Or Weinberger
Or Weinberger

Reputation: 7472

getJSON not working on IE

$(document).ready(function(){
  var timezone = "GMT";
  var num1 = Math.random();
  $.getJSON("http://178.79.191.15/json.php?num="+num1,
    function(data){
        console.log(data.hour);
      if (data.hour == 0 || data.hour == 1 || data.hour == 2 || data.hour == 3) {
        $('#pokerform').show();     
      } else {
        $('#wrongtime').show(); 
      }
    })
});

The above is my function, it's working on Chrome/FF but not in IE.

I've set up header('Access-Control-Allow-Origin: *'); on http://178.79.191.15/json.php

What could be the issue?

Upvotes: 1

Views: 595

Answers (1)

Valjas
Valjas

Reputation: 5004

You have a few issues:

For JavaScript you should use === instead of ==, especially when checking against the value of 0. You are also missing a semi-colon to close out your $.getJSON();.

Here is the revised code:

$(document).ready(function() {
    var timezone = "GMT",
        num1 = Math.random()
    ;
    $.getJSON("http://178.79.191.15/json.php?num=" + num1, function(data) {
        console.log(data.hour);
        if (data.hour === 0 || data.hour === 1 || data.hour === 2 || data.hour === 3) {
            $('#pokerform').show();
        } else {
            $('#wrongtime').show();
        }
    });
});​

Upvotes: 1

Related Questions