2017-08-17 64 views
-1

嗨我有模型與反饋的形式。模型提交後應該顯示另一個感謝模型也需要存儲本地存儲。幫我。Javascript顯示謝謝你模式提交

<div id="myModal2" class="modal fade" role="dialog"> 
<form action="" method="post" onSubmit="popUpToggle();" id="myModal2" > 
<div class="form_fields feedbackfield"> 
<textarea id="txtMessage" name="txtMessage" rows="5" class="form-control contact-input" placeholder="Message *" required></textarea> 
</div> 
<div class="form_fields"> 
<input type="submit" class="contact-submit" name="SUBMIT" value="SUBMIT"> 
</div> 
</form> 
</div> 

<div id="myModal4" class="modal fade" role="dialog"> 
     <div class="modal-dialog">      
       <div class="popupHead3"> 
        Thank you for your feedback  
       </div>  
     </div> 

的Javascript:

setTimeout(function() { 
      if(localStorage.getItem("modalPopup")){$("#myModal2").modal('hide');} 
      else{$('#myModal2').modal('show');} 

     }, 5000); 

     function popUpToggle(){   
      localStorage.setItem("modalPopup", "commit"); 
     } 

回答

0

您可以嘗試AJAXformsubmit然後用

$('#myModal4').modal({show: 'true'}); 
+0

我該怎麼做..?我給popUpToggle()作爲onSubmit – user2172424

0

請嘗試以下代碼。

$("#myModal2").submit(function(){ 
    event.stopPropagation(); 
    event.preventDefault(); 
    $.ajax({ 
    type: "POST", 
    url: /* submit url or form action url */, 
    data: $(this).serialize(), 
    success: function(d){ 
     /* do here what you want to do */ 

     $("#myModal4").modal({show: "true"}); 
    }, 
    dataType: "JSON" 
    }); 
}); 
相關問題