title: Ajax post return value
body: <p>Im using Ajax to send values to a PHP script which writes some value to a database:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      data: "action=vote_down&amp;id="+$(this).attr("id"),
      url: "vote.php",
      success: function(msg) {
          $("span#votes_count"+the_id).fadeOut();
          $("span#votes_count"+the_id).html(msg);
          $("span#votes_count"+the_id).fadeIn();                      
      }
  });
  </code></pre>
  
  <p>As you can probably tell from the <code>action=vote_down</code> the script is for a voting script. </p>
  
  <p>Im already preventing the user from voting more than once by logging there vote against there username and ID in <code>vote.php</code> and if there username and ID is already in the DB against the same post then I dont add the vote to the DB.</p>
  
  <p>I personally think that querying the database on each page load to check if the user has already voted could be quite intensive, there are many places to vote on a single page.</p>
  
  <p>So instead i'll show the user the voting option, but when they vote I want to some how return a value from <code>vote.php</code> to say they have already voted.</p>
  
  <p>Any ideas for the best approach to this?</p>