使用JQuery和AJAX更新SQL

I have an RSVP box on my website where I want people to click the tick or cross image depending on whether they are coming or not. I currently have a PHP system that updates a SQL database but it reloads the page.

I have tried this code:

$(document).ready(function() {
    var options = {
        url: 'process.php',
        type: 'post',
        data: 'attending',
        success: success
    };

    // bind to the form's submit event
    $('.attending').click(function {
        $(this).ajaxSubmit(options);
        return false;
    });

    function success(responseText, $form) {
        $(".attending").hide();
        $(".success").fadeIn();
    } 
}); 

The RSVP buttons are links with tags But I am strugling with this, any help would be appreciated!

Thanks

The ajaxSubmit function is part of the jquery forms plugin ... are you including that plugin with the page? (You didn't tag the question with jquery-forms-plugin, so I'm guessing no) If this is your first go at jQuery ajax, I'd recommend using the .ajax method first, even though it's more lines of code, to get an understanding of what's going on there.

You missed the brackets after declaring the function in your click handler, try this:

// bind to the form's submit event
$('.attending').click(function() {
    $(this).ajaxSubmit(options);
    return false;
});

Or better yet:

// bind to the form's submit event
$('.attending').click(function(e) {
    e.preventDefault();
    $(this).ajaxSubmit(options);
});