jquery文件上传 - IE回调导致对象Object [英] jquery file upload - IE callback results in object Object

查看:302
本文介绍了jquery文件上传 - IE回调导致对象Object的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有,
我知道这个问题已经存在:
jquery文件上传 - IE完成回调data.result问题

然而,我有同样的问题,不知道如何解决它。我有一些看起来像这样的工作代码(基于另一篇文章中的建议):
$ b $ pre $ if($。fn。 wl_File)$ .fn.wl_File.defaults = {
forceIframeTransport:true,
onDone:function(e,data){
var result = jQuery.parseJSON(data.result);
var filename = result [0] .name;






在Firefox,Chrome等中完美提取回调信息除IE外。但是,我仍然从IE获得一个[对象对象]。当我在Chrome中执行 console.log(data.result)时,我得到了以下结果:



<$ p $ > [{
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
}]

我不知道如何解决这个问题。根据我的代码,任何人都可以指向正确的方向吗?



仅供参考,我正在使用以下主题: http://revaxarts-themes.com/?t=whitelabel ,它调用jquery上传插件,这就是为什么我的代码看起来有点不同顶部,但它基本上是插件代码相同的东西。



任何帮助在这个令人沮丧的问题上大大地赞赏!

我从我提到的问题中找到解决方案。不过,为了满足不同的浏览器,我必须稍微扩展一下。原来的答案是正确的,如何从IE浏览器的数据,但该方法不适用于其他浏览器。我不得不添加一个if语句来查看我的浏览器类型,然后从那里继续。我处理这种情况的代码如下所示:

  if($。browser.msie){
var data_to_parse = $('pre',data.result).text();
} else {
var data_to_parse = data.result;
}
var result = jQuery.parseJSON(data_to_parse);
var filename = result [0] .name;

现在我可以操纵IE和其他浏览器的响应了!

All, I know that there is this question already out there: jquery file upload - IE done callback data.result issue

However, I'm having the same issue and don't know how to resolve it. I had some working code that looked like this (based on the recommendation in the other post):

if($.fn.wl_File) $.fn.wl_File.defaults = {
    forceIframeTransport: true,
    onDone: function (e, data) {
    var result = jQuery.parseJSON(data.result);
    var filename = result[0].name;
    }
}

Which extracts the callback information perfectly in Firefox, Chrome etc except for IE. However, I still get an [object Object] back from IE. I get the following results back when I do a console.log(data.result) in Chrome:

[{
"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"
}]

I don't know how to resolve the issue. Based on my code, can anyone point me in the right direction?

FYI, I'm using the following theme: http://revaxarts-themes.com/?t=whitelabel which calls the jquery upload plugin and that's why my code looks a little different at the top but it's basically the same thing as the plugin code.

Any help is greatly appreciated on this frustrating issue!

解决方案

I found the solution to this from the post I mentioned in my question. However, I had to expand on it a little to satisfy the different browsers. The original answer was right about how to get the data from IE but that method didn't work for the other browsers. I had to add an if statement to see what my browser type was and proceed from there. My code to handle this scenario looks like the following:

if($.browser.msie){
    var data_to_parse = $( 'pre', data.result ).text();
}else{
    var data_to_parse = data.result;
}
var result = jQuery.parseJSON(data_to_parse);
var filename = result[0].name;

I can now manipulate the response I get from both IE and other browsers!

这篇关于jquery文件上传 - IE回调导致对象Object的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆