title: Barcode Scanner Phonegap plugin; Can't save results into global variable, or save to hidden field
body: <p>Currently I am working on a phonegap that uses the Barcode Scanner plugin (v 0.6.0) with phonegap 2.9.0.  The actual barcode scanner works fine, I can get the phone to bring up the camera/scanner and read a barcode. I can even get the result.text to show up in a simple alert (as long as I do this in the callback). However, if I try to save the value of results.text into a global variable or hidden field, the value is undefined in the variable, and empty in the field.</p>
  
  <p>my current code</p>
  
  <pre><code>openBarcodeScanner();
  var code = document.getElementById('barcode').value;
  alert(code);
  
  function openBarcodeScan(viewInfo){
  var scanner = cordova.require("cordova/plugin/BarcodeScanner");
  scanner.scan(function (result){
      document.getElementById('barcode').value = result.text;
      },
      function (error){
          alert ( error );
      });
  }
  </code></pre>
  
  <p>I might very well be doing something stupid, but for the life of me can't figure it out. I would prefer to use a global variable, but the hidden field was a last ditch effort to pass the result.text outside the call back.</p>
  
  <p>EDIT: I guess this because of the asynchronous callback, but I'm not sure how get result.text outside the function.</p>