无法从Plupload获取JSON数据
问题描述:
我正在使用Plupload上传文件,它运行正常。
I'm uploading files using Plupload and it works fine.
我已经测试了*上的各种建议,但我仍然无法从我的JSON响应中获得任何合理的数据。
I've tested various suggestions found here on *, but I'm still not able to get any sensible data from my JSON respons.
在我的 upload.php
文件中,我有 echo json_encode($ result);
在我的JS中,我执行以下操作:
In my JS I do the following:
uploader.bind('FileUploaded', function(up, file, response) {
var obj = jQuery.parseJSON(response);
var obj2 = eval(response);
alert(response.toSource()); // <-- Outputs raw data
alert(obj); // <-- is NULL
alert(obj2.toSource()); // <-- Outputs eval data format
alert(obj2.logo_url); // <-- Is not working
});
警报(response.toSource());
返回:
({response:"{
\"logo_url\":\"http:\\/\\/mysite.com\\/uploads\\/3b\\/7b019482c806f9_logo.jpeg\",
\"img_id\":\"30\",
\"feedback\":{\"message\":\"File uploaded\",
\"success\":true}}",
status:200})
和 obj
为NULL。
我在这里做错了什么?
答
有很多问题
- 删除报价逃避\
- 回复+状态应该在引号中
ie
{
"response": {
"logo_url": "http: \\/\\/mysite.com\\/uploads\\/3b\\/7b019482c806f9_logo.jpeg",
"img_id": "30",
"feedback": {
"message": "Fileuploaded",
"success": true
}
},
"status": 200
}