title: ajax how to return an error message from a PHP file
body: <p>At the moment when I hover over any word a black box is always showing. If the PHP code returns text it is displayed in the black box (which it should). However I want it to return an error function if the text is not returned so I can then later change the CSS for the black box so that it has a width of <code>0px</code> instead of <code>400px</code>.</p>
  
  <pre><code>var x = ($(this).text());
  $.ajax({
      type: 'POST',
      url: 'process.php',
      data: { text1: x },
      success: function(response){
          $('#tooltip').text(response);
      }
  });
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>try 
  {
      $db = new PDO('sqlite:ordbas.db');
      $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  
  } catch(PDOException $err)
  {
      echo "PDO fel $err";
  }
  
  if (isset($_POST['text1'])) {
      $text1 = $_POST['text1'];
      $results = $db-&gt;prepare("SELECT forord FROM words WHERE sokord='$text1'");
      $results-&gt;execute();
      $row = $results-&gt;fetch();
      echo $row[0];
  }       
  </code></pre>
  
  <p>As you might have figured out there is some non-important code that I left out. I hope someone can understand and help me! Thanks!</p>