title: Scrape and display web content from another URL using JQuery/AJAX/PHP
body: <p>I need to do the following:</p>
  
  <ol>
  <li><p>Catch a URL pasted into a simple HTML text box on the paste event and save to a JavaScript variable called myURL (this code works)</p></li>
  <li><p>Send the myURL variable using AJAX to a PHP page that will scrape some content from the URL. The PHP page (webscraper.php) will save the scraped content in the database and then also display the scraped content on the HTML page (where the text box is) without reloading the page. And this step is where the code is missing and broken.</p></li>
  </ol>
  
  <p>index.html:</p>
  
  <pre><code>&lt;body&gt;
       &lt;input type="text" class="newslinkinput"/&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>URLonpaste.js:</p>
  
  <pre><code>$(document).ready(function () {
   $(".newslinkinput").bind('paste', function (e) {
       setTimeout(function () {
           var myURL = $(".newslinkinput").val()
           $.ajax({
               type: "POST",
               url: "webscraper.php",
               data: "newslink=" + myURL.val(),
               success: function (data) {}
           });
       }, 0);
     });
   });
  </code></pre>
  
  <p>webscraper.php:</p>
  
  <pre><code>&lt;?php   
  $newslink = $_POST['newslink'];
  
  require_once('ExternalScraper.php');
  
  $result = ExternalScraper::fetch($newslink);
  
  $contentA = $result-&gt;contentA;
  $contentB = $result-&gt;contentB;
  
  include "include/database.php";
  
  $insert = mysqli_query($connect, "INSERT INTO mytable (contentA, contentB) VALUES ('$contentA', '$contentB')");
  
  mysqli_close($connect);
  
  //Somehow get $contentA and $contentB to display on index.html
  //Do all this without refreshing the page
  
  ?&gt; 
  </code></pre>