Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Filedrop JSON响应_Php_Javascript_Jquery_Json - Fatal编程技术网

Php Filedrop JSON响应

Php Filedrop JSON响应,php,javascript,jquery,json,Php,Javascript,Jquery,Json,我正在使用用于jquery的filedrop插件将图像上传到我网站上的imgur。PHP脚本返回{“status”:“Imgur code:cZ8gH”} 我想将此作为警报返回,但我不知道如何执行此操作 我现在有这个 uploadFinished:function(i,file,response){ $.data(file).addClass('done'); var jsonobj = $.parseJSON(response); ale

我正在使用用于jquery的filedrop插件将图像上传到我网站上的imgur。PHP脚本返回
{“status”:“Imgur code:cZ8gH”}

我想将此作为警报返回,但我不知道如何执行此操作

我现在有这个

    uploadFinished:function(i,file,response){
        $.data(file).addClass('done');
        var jsonobj = $.parseJSON(response);
        alert(jsonobj.status);
        // response is the JSON object that post_file.php returns
    }

但它不起作用?

我不知道filedrop插件,但当没有指定数据类型时,jQuery尝试使用响应的MIME类型解析ajax响应

因此,jQuery可能已经解析了响应

试用

response.status
为了帮助调试,最好使用带有控制台(或Firebug Lite)的浏览器并调用

console.log 
而不是使用
警报
,特别是因为
控制台
可以打印对象


由于

的原因,可能已经解析了响应。
response.status
有效吗?是的!谢谢,我没有想到,使用带有控制台(或Firebug Lite)的浏览器并调用
console.log
而不是
alert
@Thomas也许你应该从你的评论中做出一个回答,这样你就可以得到信任了?)因为这是一个答案:默认情况下(如果ajax调用参数中没有发送数据类型),jQuery尝试从其内容猜测响应类型——如果结果是JSON,则自动解析它。)如果我正确阅读了文档,jquery只使用mime类型,而不使用内容来描述响应的类型。在本例中,它看起来可能是解析它的插件。