conbask
conbask

Reputation: 10061

AJAX Update Separate Element

I'm developing a voting system using PHP and when I click on the "Vote Up" or "Vote Down" links for a particular item, I'd like the "vote.php" script to be run and the "Votes" value to be updated to reflect it's new value without the page refreshing. I'll need to be making a POST request via Ajax and I'd prefer to be able to do this using jQuery.

Any ideas?

Upvotes: 0

Views: 107

Answers (1)

Jan Dragsbaek
Jan Dragsbaek

Reputation: 8101

this can easily be achieved by use of .ajax and the success parameter from the .ajax function within jquery

its all here: http://api.jquery.com/jQuery.ajax/

So, example:

$.ajax({
  url: 'ajax/test.html',
  success: function(data) {
    $('.result').html(data);
  }
});

Upvotes: 1

Related Questions