I'm uploading files using Plupload and it works fine.
I've tested various suggestions found here on Stackoverflow, but I'm still not able to get any sensible data from my JSON respons.
In my upload.php
file I have echo json_encode($result);
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
});
The alert(response.toSource());
returns this:
({response:"{
\"logo_url\":\"http:\\/\\/mysite.com\\/uploads\\/3b\\/7b019482c806f9_logo.jpeg\",
\"img_id\":\"30\",
\"feedback\":{\"message\":\"File uploaded\",
\"success\":true}}",
status:200})
and obj
is NULL.
What am I doing wrong here?
var uploader = $("#multi_upload").pluploadQueue();
uploader.bind('FileUploaded', function (up, file, res) {
var res1 = res.response.replace('"{', '{').replace('}"', '}');
var objResponse = JSON.parse(res1);
alert(objResponse.fn);
});