title: Download picture from database to display via JavaScript?
body: <p>I am developing mobile applications, and I was thinking, if I need to download a picture from a server, I cannot actually run the PHP natively (I am using a <a href="http://en.wikipedia.org/wiki/PhoneGap" rel="nofollow">PhoneGap</a> type setup), so how could I download a picture from a database, run it though JavaScript and then display it to the user?</p>
  
  <p>I would imagine something like:</p>
  
  <ol>
  <li>Ajax request,</li>
  <li>Return HTML string of binary data</li>
  <li>Do some stuff to that?</li>
  </ol>
  
  <p>Or</p>
  
  <ol>
  <li>Ajax request,</li>
  <li>Return a HTML string of reference to the picture, for example: <code>picture1.jpg</code>.
  In JavaScript, write something like <code>document.write &lt;img src="http://blahh/img/"+imagePath</code></li>
  </ol>
  
  <p>I'm not sure what the best way to do this is.</p>