7

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');
)};
bpeterson76
  • 12,918
  • 5
  • 49
  • 82
m_gunns
  • 551
  • 1
  • 16
  • 29

3 Answers3

8

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.

Community
  • 1
  • 1
bpeterson76
  • 12,918
  • 5
  • 49
  • 82
1

Since its a old post this answer may be helpful to other seekers.

There may be two reasons why getJson not working in IE.

1.Either Jsonp requests which resolved by adding

 &callback=? or &callback=?

2.Set ajax catch.

$.ajaxSetup({ cache: false });

If still you have problem, it may be because of the cross-platform API usage.

Sakthivel
  • 1,890
  • 2
  • 21
  • 47
0

I'll go for the well known cross domain policy issue with jquery and IE.

This article explain well the solution:

http://cypressnorth.com/programming/cross-domain-ajax-request-with-json-response-for-iefirefoxchrome-safari-jquery/

svassr
  • 5,538
  • 5
  • 44
  • 63