title: AJAX/JQuery success:/error: function manipulation
body: <p>Having some trouble with AJAX/JQuery. Here is the context of my problem followed by a code sample:</p>
  
  <p>What I am attempting to do is call a PHP script called getInfo.php and check whether or not some data is contained within a database. I can write queries easily enough but in terms of the code sample below how can I "tell" the success function to fail if it cannot find data in the database and run the error function instead?</p>
  
  <pre><code>$(document).ready(function(){
          getInfo();
          function getInfo(){
              $.ajax({
                  type: "GET",
                  url: "getInfo.php",
                  data: "do=getInfo",
                  cache: false,
                  async: false,
                  success: function(result) {
                      $("#myInfo").remove();
                      alert("Data found");
                  },
                  error: function(result) {
                      alert("Data not found");
                  }
              });
          }
  });
  </code></pre>
  
  <p>Any advice would be greatly appreciated. =)</p>