php - How do I return data via Ajax using Plupload on Upload Complete? -


i've been trying last few hours something... pluploader upon completion of queue no avail.

here js code:

var uploader = $('#pluploaddiv').pluploadbootstrap();  uploader.bind("uploadcomplete", function(up, files) {     var obj = $.parsejson(response.response);     alert(obj.result);  }); 

on last line of upload.php script, have:

die('{"jsonrpc" : "2.0", "result" : "'.$_request['unitid'].'", "id" : "id"}'); 

this makes sense me... it's not working, files upload without problems, alert doesn't fire off... there no response whatsoever.

thoughts?

edit new code solution

the js i'm using (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 stayed same, last line of code:

die('{"jsonrpc" : "2.0", "result" : "'.$_request['unitid'].'", "id" : "id"}'); 

so when create shell row associate images in upload script, pass row id original form hidden input field via fileuploaded event bound plupload object.

<input type="hidden" name="vehicle_id_value" id="vehicle_id_value" value="" /> 

works charm!

several files have been uploaded part of upload process. individuals responses not avalaible anymore when on uploadcomplete stage. if want display info specific file upload, should bind fileuploaded event instead of uploadcomplete. :

uploader.bind('fileuploaded', function(upldr, file, object) {     var mydata;     try {         mydata = eval(object.response);     } catch(err) {         mydata = eval('(' + object.response + ')');     }     alert(mydata.result); }); 

hope help


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -