I'm unfortunately required to support IE8 and I'm unable to get even a simple $.getJSON
request to work properly.
Here is the code:
url = "http://www.somejson.com/data.json";
$.getJSON(url, function(data) {
var funds = []; var benchmarks = [];
funds.push(data.funds); benchmarks.push(data.benchmarks);
$.each( data.funds, function(key, value) {
var ticker = key;
// Monthly:
var appendToDaily = function(ticker) {
$.each($("#"+ticker), function(key, value, index) {
$(this).children("td").filter(":nth-child(1)").html( '<td>'+funds[0][ticker].name+'</td>' );
$(this).children("td").filter(":nth-child(2)").html( '<td>'+ticker+'</td>' );
$(this).children("td").filter(":nth-child(3)").html( '<td>'+funds[0][ticker].fund.inception_date+'</td>' );
});
};
appendToDaily(ticker);
});
});
This code works just fine in Chrome, Firefox, and IE9+.
I've tried a few things to fix this with no success:
- I've tried to use the
$.ajax
method instead. - Set the header for the JSON data to:
response.setContentType("text/javascript; charset=UTF-8");
as suggested here. - Added this snippet before the
$.getJSON
:$.ajaxSetup({ cache: false });
then reset it to true just before terminating the call as suggested here. - I've explicitly included
json2.js
just in case. - Reverted to JQuery
1.11.0.min.js
just in case.
When I attempt to run this code, I get several errors saying that "fund" and "funds" are undefined. I also notice that absolutely nothing inside the $.getJSON
callback function fires; even an alert()
is ignored.
I'm kind of at my wit's end here so any suggestions would be greatly appreciated! Thanks in advance.