Im using Ajax to send values to a PHP script which writes some value to a database:

```
$.ajax({
    type: "POST",
    data: "action=vote_down&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();                      
    }
});

```

As you can probably tell from the `action=vote_down` the script is for a voting script. 

Im already preventing the user from voting more than once by logging there vote against there username and ID in `vote.php` and if there username and ID is already in the DB against the same post then I dont add the vote to the DB.

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.

So instead i'll show the user the voting option, but when they vote I want to some how return a value from `vote.php` to say they have already voted.

Any ideas for the best approach to this?