Hello, I'm working on an application wherein I have a checkbox that triggers an ajax call to update a database. Should the database operation fail, I want the checkbox to retain its old state. I'm having trouble making this work. The closest I've gotten is that if I bind the 'click' event of the checkbox and call event.preventDefault() in the handler, the box changes state then reverts once the handler exits. I'm testing using an alert() in the handler rather than the actual ajax call. If I bind to the change event instead, the box changes and stays changed, despite the preventDefault call. Perhaps also relevant is that getting the box's state (via $("#mycheckbox").attr('checked')) within the handler gives the new state.
Any ideas on how to get complete control over whether the box gets checked or not, or even just insight into what's going on here in terms of the event model. I am new to jquery and javascript in general, so I'm bringing a lot of ignorance to the table. Thanks in advance.