I have been trying for the last few hours to get something ... something back from the pluploader after the completion of the queue to no avail.
Here is my JS code:
var uploader = $('#pluploadDiv').pluploadBootstrap(); uploader.bind("UploadComplete", function(up, files) { var obj = $.parseJSON(response.response); alert(obj.result); });
In the very last line of the upload.php script, I have:
die('{"jsonrpc" : "2.0", "result" : "'.$_REQUEST['unitID'].'", "id" : "id"}');
This makes sense to me ... but it doesnβt work, the files load without problems, but the warning does not even work ... there is no answer at all.
Thoughts?
EDIT WITH NEW CODE AS SOLUTION
JS I use (thanks jbl):
var uploader = $('#pluploadDiv').pluploadBootstrap(); uploader.bind('FileUploaded', function(upldr, file, object) { var myData; try { myData = eval(object.response); } catch(err) { myData = eval('(' + object.response + ')'); } $("#vehicle_id_value").val(myData.result); });
Upload.PHP script remains the same, the last line of code:
die('{"jsonrpc" : "2.0", "result" : "'.$_REQUEST['unitID'].'", "id" : "id"}');
So basically, when I create a shell line for linking images in the upload script, I pass the line ID back to the original form in the hidden input field through the FileUploaded event associated with the plupload object.
<input type="hidden" name="vehicle_id_value" id="vehicle_id_value" value="" />
It works like a charm!