2017-06-30 127 views
0

所以我有一個模式,它有這種形式。表格上有一個按鈕,其中顯示「保存&退出」。點擊它,通過ajax正確地將數據保存到數據庫中如何同時關閉模式並刷新父頁?模式關閉時刷新父頁面

代碼開放模式

<button type="button" class="float-right" data-toggle="modal" data-target="#attribute_contact"> 
          <i class="fa fa-pencil"></i> 
         </button> 

莫代爾

<div class="modal fade" id="attribute_contact" role="dialog"> 
        <div class="modal-dialog modal-lg"> 

保存&關閉: -

<input type="submit" name="submit" value="Save & Close" id="submit_button" class="btn btn-success"> 

AJAX

$("#left_side_profile").submit(function(e){ 
     e.preventDefault(); 
     // alert("submitted"); 
     $.ajax({ 
      type: 'POST', 
      url: 'ajax.php', 
      data: $('#left_side_profile').serialize(), 
      success: function (data) { 
       window.location.href = "editprofile.php"; 
      } 
      }); 
}); 

任何幫助將不勝感激。

+0

F12,控制檯日誌裏有什麼? – mkaatman

+1

'window.location.href =「editprofile.php」;'沒有做這項工作? –

+0

爲什麼關閉模式,如果你只是要刷新頁面?只需刷新頁面... – Steve

回答

0

在成功函數 1.關閉模態

$("#attribute_contact").modal('hide'); 
  • 重新加載該頁面

    location.reload();

    成功:function(data){(「#attribute_contact」)。modal('hide'); location.reload(); }