1

我的 JSONP 调用在 MSIE7 中出现对象错误。我已经修复了我得到的 JSON 对象。(它之前没有引号之间的键值)有了这个我认为我已经修复了它,因为它确实可以从静态文件中工作。但是,当我开始工作并再次对其进行测试时,它再次返回了对象错误。

我也尝试使用普通 &.getJSON(url, callback) 并添加了 ?callback=? 到网址,但无济于事

这是调用本身:

$.ajax({
  type:'GET',
  url: url,
  error:function (xhr, ajaxOptions, thrownError) {
alert(xhr.statusText);
alert(xhr.responseText);
alert(xhr.status);
alert(ajaxOptions);
alert(url);
alert(thrownError);
  },
  success:successHandler,
  dataType:'jsonp',
  jsonp:'_jsonp',
  jsonpCallback:'jsonpCallback',
  cache:true
});

和 json-object 的片段

jsonpCallback({"positionInfoContainer":[{
"familyId":1,
"filterId":14,
"labels":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157],
"positionInfoType":"TopConserved",
"values":[14.8284314,47.9779412,42.7696078,17.8921569,14.084507,56.4605021,30.6184936,26.2094305,62.1406728,48.2568807,35.79719,21.3064713,23.5365854,16.2606577,17.5790754,18.2260024,23.8095238,26.6826923,22.7354529,18.2963407,35.7271095,26.2843489,27.1479714,42.1334923,39.3452381,27.0833333,26.2938727,25.2825699,45.8753709,22.3606168,12.9300119,26.8683274,58.4469472,45.1096621,54.5346769,89.2772512,84.7748815,21.5047393,48.6390533,89.5266272,62.8622117,98.2321744,19.8823529,29.9059929,95.2996475,25.1465416,42.170088,25.6154748,97.6567077,96.3700234,40.2339181,31.5789474,95.1546994,85.0554583,46.4723032,26.6472303,25.7292882,49.0686845,24.1860465,75.9001161,35.5981417,45.9349593,21.5652174,45.6018519,32.2916667,41.4591778,32.8894036,27.5622467,66.7631731,48.377752,35.718441,19.7674419,48.0232558,35.6020942,46.9565217,47.8235636,31.5299593,29.2952825,22.6031377,39.9186519,23.0679837,22.5,37.8488372,17.5305766,29.5749705,31.3679245,84.9468713,30.7328605,35.262847,47.9031305,59.704142,45.7617072,77.6066351,42.2894425,32.3634204,73.9440809,36.7261905,40.4407385,20.8358571,16.0120846,23.095526,47.9758308,55.4682779,17.9564692,52.6634383,53.7855845,44.4848485,22.1952699,23.1655549,24.211165,15.9684274,49.6660595,90.0609756,25.6253813,14.5731707,47.008547,43.2844933,15.0701647,23.6552567,28.247549,20.5555556,51.0166359,60.2595797,34.6510191,46.3821892,81.5298507,75.4057428,33.7515684,31.1279143,73.6277603,34.0290955,25.3164557,68.504436,79.2116974,25.9070656,37.0772176,34.7826087,18.5137732,33.1410256,28.0128205,18.7902188,50.1295337,25.2111761,46.0286458,31.3559322,18.5016287,21.577575,58.7084149,28.7542088,38.5185185,36.6644159,65.8503401,57.3960464,24.467354,85.4482759,43.8365651,45.0174216]
}]
});

当我使用静态文件而不是 dataType:"jsonp" - dataType:"text json" 并将 jsonp 和 jsonpCallback 注释掉时,此代码段有效。

此代码在 Opera、Chrome 和 Firefox 中完美运行。(虽然所有最新版本)

4

0 回答 0