Noah Wetjen
Noah Wetjen

Reputation: 1785

Jquery .get not working in Firefox and IE

I'm using the awesome GoSquared API to get the number of current visitors on my Site.

I have build a Jquery Script, that automatically updates the number every two seconds with Jquery .get, but this doesn't seem to work in IE and Firefox.

JSFiddle

Thanks :)

Upvotes: 0

Views: 1716

Answers (1)

Matt Zeunert
Matt Zeunert

Reputation: 16561

In Firefox data is a string for some reason. You can specify the data type of the response explicitly:

$.get('url', function(){}, "json");

Otherwise you can turn it into an object like this:

if (typeof data === "string"){
    data = JSON.parse(data);
}

Upvotes: 3

Related Questions