【发布时间】:2017-05-01 07:40:36
【问题描述】:
在 Internet Explorer 中使用 jsonp 时遇到问题。
我的代码:
$.ajax({
url: 'my url',
cache: false,
dataType: "jsonp",
crossDomain: true,
async: true,
success: function(data) {
i = 0;
for (var ix=0;ix<data.length;ix++) {
item = data[ix];
v = item['value']
在 chrome 上一切正常,我循环数据并获取所有值“v”。
在 Internet Explorer 上,我得到了正确的数据,但是当我迭代时,“项目”是错误的。 “data”是正确的,“ix”是正确的,但“item”是不正确的。
如果我查看数据,我有一个包含 s“值”的项目的列表。 但是“item”对于“[prototype]”、“arguments”、“caller”和“prototype”来说有些奇怪。
你有什么想法吗?谢谢
【问题讨论】:
-
你能显示
console.log(JSON.stringify(data))的输出吗? -
您好,您可以在这里查看脚本:actecil.fr/agenda-des-formations
-
输出打印在控制台中。 pastebin 中的输出:pastebin.com/LVeHvsvR
-
那里的任何对象都没有
value属性。 -
第一个看起来像
{"location":"Marseille","formations":[{"dates":["Mardi 16 Mai","Mercredi 17 Mai","Jeudi 18 Mai 2017"],"sectors":["Généraliste"],"wordpress_page_id":"catalogueformationscnil/catalogue-des-formations-cnil-formations-labellisees-par-la-cnil/cil","formation":"Formation Labellisée : Exercer le métier de correspondant Informatique et Libertés","logo":"https://tools.actecil.fr/media/actecil_intraapps/formation/2016/11/label-actecil-formation-CIL.png","formation_id":2}]}
标签: javascript jquery internet-explorer jsonp