Php json返回数据在IE或Chrome中不起作用

Php json返回数据在IE或Chrome中不起作用,php,json,uploadify,Php,Json,Uploadify,我在使用Uploadify后返回JSON数据时遇到问题 此代码适用于Firefox,但不适用于IE 9或Google Chrome。 这是用于上载的脚本: jQuery("#uploadify_gallery").uploadify({ 'queueID' : 'fileQueue', 'uploader' : siteURL + '/wp-content/plugins/uploadify/uploadify.swf',

我在使用Uploadify后返回JSON数据时遇到问题

此代码适用于Firefox,但不适用于IE 9或Google Chrome。
这是用于上载的脚本:

     jQuery("#uploadify_gallery").uploadify({
        'queueID'        : 'fileQueue',
        'uploader'       : siteURL + '/wp-content/plugins/uploadify/uploadify.swf',
        'script'         : siteURL + '/wp-content/plugins/uploadify/uploadify_gallery.php',
        'fileExt'        : '*.jpg;*.jpeg;*.png',
        'auto'           : true,
        'multi'          : true,
        'method'         : 'POST',
        'buttonImg'      : siteURL + '/wp-content/themes/storelocator/img/buttons/img_upload_grey_bg.png',
        'cancelImg'      : siteURL + '/wp-content/plugins/uploadify/cancel.png',
        'queueSizeLimit' : 20,
        'scriptData'     : {'entity':jQuery('#entity').val(),'entity_id':jQuery('#entity_id').val()},
        'onComplete'     : function(event, queueID, fileObj, response, data) {

          alert('test'); // <-- THIS WORKS 

          //This makes the json response readable
          var result = eval("(" + response + ")");
          alert(result.toSource()); // <-- this never fires
        },
      });
它昨天起作用了,我已经开始工作了

有什么建议可以帮助我完成这项工作吗?

eval();这不是一个好的选择,它被认为是相当糟糕的,因为它在InternetExplorer中不起作用,至少在旧的浏览器中是这样。看看这个

您将以json对象的形式获得响应,因此不必使用eval,只需使用each循环它

$(response).each(function(index, value) {
    console.log(value);
});
有关每种方法的更多信息,请查看eval();这不是一个好的选择,它被认为是相当糟糕的,因为它在InternetExplorer中不起作用,至少在旧的浏览器中是这样。看看这个

您将以json对象的形式获得响应,因此不必使用eval,只需使用each循环它

$(response).each(function(index, value) {
    console.log(value);
});

有关每种方法的更多信息,请检查服务器返回的值并验证它是否为有效的JSON(例如使用)


之后,您可以使用将响应字符串转换为对象。

检查服务器返回的值并验证它是否为有效的JSON(例如使用)


之后,您可以使用将响应字符串转换为对象。

Eval不正确。不惜一切代价避免它。另外,服务器返回到脚本的JSON是什么样子的?Eval不好。不惜一切代价避免它。另外,服务器返回到脚本的JSON是什么样子的?是的,我发现了这个,这就是我现在使用的。谢谢:)是的,我发现了这个,这就是我现在使用的。谢谢:)