Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$.getJson not working in IE

Ok, for some reason my getJson is not working. I am pulling some stock information and it works in all major browsers except IE.

I have created a JSfiddle here: http://jsfiddle.net/qZhSk/

If anyone can help me understand what I am doing wrong it will be SUPER helpful.

thanks!

EDIT

I found the solution myself. The issue was in my URL query. If anyone else has this issue here is the answer:

var url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20WHERE%20symbol%3D'NPO'&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";

        $.getJSON(url + "&format=json&callback=?", function(data) {
        var items = [];

        $.each(data.query.results.quote, function(key, val) {

            items.push('<li id="' + key + '">' + val + '</li>');
        });

        $('<ul/>', {
            'class': 'my-new-list',
            html: items.join('')
        }).appendTo('body');
)};
like image 489
m_gunns Avatar asked Dec 09 '11 16:12

m_gunns


1 Answers

Technically, I think you're violating the Same Origin Policy on this one. By definition, you can't do a JSON get from a domain other than your own....and getting data from Yahoo is certainly a different server than jsFiddle's. There is a similar issue reported here. The CORS exceptions they list are IE up to version 10, which would explain the issue perfectly.

The problem could be solved by using a "?" in your callback handler. See this stack article for more info.

like image 150
bpeterson76 Avatar answered Oct 06 '22 02:10

bpeterson76