我正在使用jquery的文件删除插件将图像上传到我网站上的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
}
但它不起作用?
我不知道
文件删除插件,但是当没有指定数据类型时,jQuery尝试使用响应的MIME类型解析ajax响应。
因此,响应可能已经被jQuery解析了。
尝试使用
response.status
为了帮助调试,最好使用带有控制台(或Firebug Lite)的浏览器并调用
console.log
而不是使用alert
特别是因为console
可以打印对象
感谢@raina77ow