user1843591
user1843591

Reputation: 1146

Handle Success from AJAX Call

I would like to handle a successful call from the submit below and reload the current page. How can i best achieve this?

$('#modal-confirm').click(function() {
    $(form).ajaxSubmit();
    $(form).resetForm();
    $('#myModal').modal('toggle');
});

Upvotes: 0

Views: 101

Answers (3)

user1843591
user1843591

Reputation: 1146

    $(document).ajaxSuccess(function() { // http://api.jquery.com/ajaxSuccess/
     location.realod();
    })
    $('#modal-confirm').click(function() {
        $(form).ajaxSubmit();
        $(form).resetForm();
        $('#myModalOne').modal('toggle');
    });

Upvotes: 0

klewis
klewis

Reputation: 8389

You can perhaps try this out..

$('#modal-confirm').on("click", function(e){
  e.preventDefault();
  $.ajax({
    url     : '...'
  }).done(function(data) {
  //handle your conditions here once the request is successful.  if conditions are met, then...
    location.reload(true);
  });
});

Upvotes: 0

Adil Shaikh
Adil Shaikh

Reputation: 44740

You can pass option to ajaxSubmit()

$(form).ajaxSubmit({
   success:function(){
     alert("complete");
     // do other stuff
   }
});

Upvotes: 1

Related Questions