简体   繁体   English

处理来自AJAX呼叫的成功

[英]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');
});

You can pass option to ajaxSubmit() 您可以将选项传递给ajaxSubmit()

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM