title: How do I return data via Ajax using Plupload on Upload Complete?
body: <p>I've been trying for the last few hours to get something... anything back from the pluploader upon completion of the queue to no avail.</p>
  
  <p>Here is my JS code:</p>
  
  <pre><code>var uploader = $('#pluploadDiv').pluploadBootstrap();
  
  uploader.bind("UploadComplete", function(up, files) {
      var obj = $.parseJSON(response.response);
      alert(obj.result);
  
  });
  </code></pre>
  
  <p>On the very last line of the upload.php script, I have:</p>
  
  <pre><code>die('{"jsonrpc" : "2.0", "result" : "'.$_REQUEST['unitID'].'", "id" : "id"}');
  </code></pre>
  
  <p>This makes sense to me... but it's not working, the files upload without problems, but the alert doesn't even fire off... there is no response whatsoever.</p>
  
  <p>Thoughts?</p>
  
  <p><strong>EDIT WITH NEW CODE AS A SOLUTION</strong></p>
  
  <p>The JS that I'm using (thanks jbl):</p>
  
  <pre><code>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);
  });
  </code></pre>
  
  <p>Upload.php script stayed the same, last line of code:</p>
  
  <pre><code>die('{"jsonrpc" : "2.0", "result" : "'.$_REQUEST['unitID'].'", "id" : "id"}');
  </code></pre>
  
  <p>So basically when I create the shell row to associate images to in the upload script, I pass the row ID back to the original form into a hidden input field via the FileUploaded event that is bound to the plupload object.</p>
  
  <pre><code>&lt;input type="hidden" name="vehicle_id_value" id="vehicle_id_value" value="" /&gt;
  </code></pre>
  
  <p>Works like a charm!</p>