【问题标题】:JSON syntax error in IE8?IE8 中的 JSON 语法错误?
【发布时间】:2013-06-11 19:09:29
【问题描述】:

我有一个网站在大多数浏览器中运行良好,但我开始在 IE8 中遇到错误,说 JSON 未定义。互联网告诉我加入 json2.js,一切都会好起来的。

现在它给出了这个错误:

“语法错误”第 204 行字符 7”

这是第 204 行:

var data = JSON.parse(jqXHR.responseText);

我已经尝试过这些事情:

1. <!DOCTYPE html>
2. <meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
3. <script src="http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.min.js"></script>

我验证的 JSON 是有效的 JSON,但我没有想法。接下来我应该看哪里?

编辑 2:

如果我只是临时发布链接会更容易:http://pilot032013.herokuapp.com/address/51376f833ef9eb361f354ebc/

编辑 1:

function getUncuratedBuildingSuccess(jqXHR, textStatus) {
  //console.log(jqXHR.responseText);
  var data = JSON.parse(jqXHR.responseText);
  CURRENT_BUILDING_ID = data.id;
  //Load Images
  generateImageUrls(data.id);

  //Some point soon, I want to have a building object reflect the database
  building_footprint = fixBrokenFootprint(data.points);
  var building = new google.maps.Polygon({
      path: building_footprint,
      strokeColor: "#6f298b",
      strokeOpacity: 0.8,
      strokeWeight: 2,
      fillColor: "#ad2390",
      fillOpacity: 0.35
  });
  extendBounds(building);

  building_location = new google.maps.LatLng(data.center[1], data.center[0]);
  building.setMap(map);
  displayAddress(data.dte_addresses);
  displayGSVImage(data.dte_addresses);
  displayParcel(data.parcel_id);
  displayStatus(replaceAmbig(data.override));
  //displayPastVotes(data.id);
}

这是 jqXHR.responseText 中保存的 JSON:

{"suffix": "", "owner_mail_state": "None", "parcel_id": "4562354", "street_name": "", "owner_mail_zipcode": "None", "living_area": "None", "imaging_runs": ["20130307_004341_4"], "owner": "None", "num_floors": null, "id": "51424ad73ee3eb75fc5deae1", "city": "Boston", "owner_mail_address": "None", "energy_score_raw": "24.5240226853", "structural_class": "None", "zipcode": "49525", "state": "MI", "override": "None", "assessor_lot": "None", "street_num": "", "owner_mail_city": "None", "geocoded_address": [], "unit_num": "None", "use_description": "None", "vertical_panoramas": [["20130307_004341_4_r_1482539_mts", "20130307_004341_4_r_1482524_mts", "20130307_004341_4_r_1482555_mts", "20130307_004341_4_r_1482570_mts"]], "building_style": "None", "assessor_map": "None", "exterior_material": "None", "fireplace": "None", "roof_type": "None", "use_code": "None", "year_built": "None", "center": [-85.6279876548728, 43.028673273958084], "energy_score_city": 69, "year_remodeled": "None", "air_conditioner": "None", "created_at": "2013-06-11T15:20:12.301190", "heat_type": "None", "owner_occupied": "None", "contract": "dte", "energy_score_neighbors": 79, "points": [[-85.6279345148065, 43.0287278589084], [-85.62793027273129, 43.0286178277214], [-85.6280408213034, 43.0286193662203], [-85.6280455189338, 43.0287278763051], [-85.6279345148065, 43.0287278589084]], "num_units": "None", "yme_addresses": [{"_changed_fields": [], "site_id": "3390379", "_initialised": true, "_created": false, "_data": {"city": "Boston", "suffix": "ROAD NE", "state": "MA", "street_name": "4 MILE", "is_contracted": null, "zipcode": "49525", "prefix": null, "street_num": "1665"}, "ser_seq": "1"}], "_id": "None", "gross_area": "None"}

【问题讨论】:

  • 给出你的数据响应。如果您向我们提供 ajax 请求数据,我们会知道的
  • 尝试您的链接时,在 IE8 模式下,我在 json3 库中加载时遇到 javascript 错误。这似乎是这个错误:github.com/bestiejs/json3/issues/35 在使用非缩小版本或 3.2.5 时显然已解决。分支。不确定这是整个问题还是还有其他问题。请注意,IE8 在标准模式下不需要 JSON polyfill,它应该可以开箱即用。
  • 给定链接中的错误:“SCRIPT5007:无法获取属性“长度”的值:对象为空或未定义的 json3.min.js,第 13 行字符 93”。此外,它引用了 json3 而不是 json2,如您上面所述。
  • 糟糕,我忘记推送更改了。我已经调试过了。我现在正在重新启动 heroku 应用程序。编辑:它没有重新启动。如果你还在的话,请再看看。谢谢。

标签: javascript json internet-explorer flask


【解决方案1】:

如果是 a 的 url,您可能会遇到这种类型的错误

 <script src="...url..."></script>

不返回 javascript

【讨论】:

    【解决方案2】:

    在您的链接上找到脚本注释。

    GET http://cdnjs.cloudflare.com/ajax/libs/json3/3.2.5/json3.min.js 404 (Not Found) pilot032013.herokuapp.com:31
    

    再次检查您的 JavaScript CDN,确保其正常工作。

    【讨论】:

    • 检查并修复。现在我有一个长度未定义的新错误。我猜这是一个脚本错误。
    • 请在 IE8 上评论 console.log()。它不知道控制台
    猜你喜欢
    • 2023-01-30
    • 2020-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多