gpt4 book ai didi

jquery - 确定 IE8 及更低版本的 JSON 中解析的内容

转载 作者:行者123 更新时间:2023-12-01 08:14:38 27 4
gpt4 key购买 nike

所有,我有以下代码:

onDone: function (e, data) {
var result = jQuery.parseJSON(data.result);
var uploadType = result.upload_type;
var filename = result.name;
var insert_id = result.insert_id;
}

当我运行此命令时,我从 IE 收到以下错误:

Message: 'upload_type' is null or not an object

When I do a console.log(data.result) in Chrome I get the following data:

 [{
"name": "1_3266_671641333369_14800358_42187036_5237378_n.jpg",
"size": 35535,
"type": "image\/jpeg",
"url": "\/web\/upload\/1_3266_671641333369_14800358_42187036_5237378_n.jpg",
"thumbnail_url": "\/web\/upload\/thumbnails\/1_3266_671641333369_14800358_42187036_5237378_n.jpg",
"delete_url": "\/web\/upload.php?file=1_3266_671641333369_14800358_42187036_5237378_n.jpg",
"delete_type": "DELETE",
"upload_type": "video_montage",
"insert_id": "288"
}]

我试图了解为什么我在 IE8 中收到错误消息,但我看不到正在解析的内容。当我确实发出这样的警报时:

var result = jQuery.parseJSON(data.result);
alert(result)

我得到了 null,但不知道为什么。

非常感谢有关如何读取它或为什么我的解析 JSON 结果为空,即使我返回的字符串中有数据的帮助!

谢谢!

最佳答案

我终于找到了这个问题的解决方案,这是一个问题,因为 IE 不支持 XHR 上传。您可以通过查看这篇文章找到对此的详细说明:

jquery file upload - IE done callback data.result issue

但这并不能完全解决我的需求,因为该代码仅适用于 IE,而我需要跨浏览器工作。我稍微更新了我的代码,如果您在此处查看接受的答案:

jquery file upload - IE callback results in object Object

您将了解如何处理来自 IE 的 JSON 响应以进行 XHR 类型的上传!

关于jquery - 确定 IE8 及更低版本的 JSON 中解析的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11442565/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com