title: What is the best way to utilize the open() javascript function when working with mysql databases?
body: <p>I am working to create a shorter <code>URI</code> for my photos and pdf docs which I am pulling from a <code>mysql database</code>. They are stored as <code>blobs</code>. </p>
  
  <p>When I extract my photos or <code>pdfs</code> as <code>blobs</code> from my database, I encode them in <code>base64</code>. This creates a ridiculously long <code>img src</code>. I want to shorten this by using <code>AJAX</code>. The problem I am having is that I am not sure what to set as my link in the <code>open()</code> function in javascript. </p>
  
  <ol>
  <li>The link appears without the URI conversion </li>
  </ol>
  
  <p><code>&lt;img src="data:image/jpg;base64,**65,648-character-blob**" class="photo" id="image" alt=""&gt;</code> </p>
  
  <ol start="2">
  <li>The link after the URI conversion. </li>
  </ol>
  
  <p><code>&lt;img src="blob:http://www.somedomain.com/7ab702ba-ba1f-4cac-9bc7-6f15d91ba2c3" class="photo" id="image" alt=""&gt;</code></p>
  
  <p>The specific code is below with</p>
  
  <p><code>xhr.open("GET", "", true);</code></p>
  
  <p>The beginning of my code so far is below:</p>
  
  <pre><code>    const xhr = new XMLHttpRequest();
  
      //console.log(xhr.readyState);
  
      xhr.onreadystatechange = function () {
  
          // check readyState and status
          if (this.readyState == 4 &amp;&amp; this.status == 200) {
                document.getElementById("image").innerHTML = this.responseText;
          }
          console.log(responseText);
      };
      xhr.open("GET", "what should be here?", true);
  
      xhr.send();
  </code></pre>
  
  <p>I console.log document, I can see all of my photo links as shown in example #1 above. </p>
  
  <p>I console.log xhr.responseText, I see only the first link in base64. I need to extract that img src information. </p>
  
  <p>I found several videos to perform this transition. However, none of the deal with results from a database. They all reference a file directly.</p>