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');
)};

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

That's exactly what I noticed. Basically you'll need to add a &callback=? to the end of your url string and you're golden
The weird thing is that it worked in Firefox. edit ah - CORS
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.

Comments

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.