I have problems returning JSON data after using Uploadify.
This code works in Firefox, but not in IE 9 or Google Chrome.
This is the script script for Uploadify:
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
},
});
This is the code I test with in uploadify_gallery.php:
$res = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($res);
It worked yesterday, and I’ve got it working on
Any suggestions on how I can make this work?
Inspect the value returned by the server and verify that it is valid JSON (using JSONLint for example).
After that you can use
jQuery.parseJSON()to convert the response string into an object.