AnApprentice
AnApprentice

Reputation: 110950

jQuery - given a form. How to bind to alert AFTER the submit, ajax success

w jQuery is it possible to bind a success event to a particular form outside of the actual $.ajax, and in a way that doesn't bind to all ajax calls just the one in particular?

Upvotes: 0

Views: 420

Answers (2)

Patrick Evans
Patrick Evans

Reputation: 42736

Define the function as normal and just pass the name

example

<script>
function submitSuccess(data)
{


}

$.ajax({
....
success: submitSuccess,
...
});
</script>

Upvotes: 1

josh3736
josh3736

Reputation: 144862

Of course you can specify a success callback for any call to $.ajax:

$.ajax({
    // ...
    success: function(r) {
        // Callback code here
    }
});

But from how I'm reading your question, I'm not sure this is what you're looking for. How do you currently have the call to $.ajax hooked up?

Upvotes: 0

Related Questions