Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
22
rated 0 times [  25] [ 3]  / answers: 1 / hits: 15195  / 9 Years ago, mon, december 28, 2015, 12:00:00

I have code like this :



$(#savedata).submit(function(e){
e.preventDefault();
$.ajax({
type : 'POST',
data: $(#savedata).serialize(),
url : <?php echo site_url('ppdb/simpan_data/'.$jenjang);?>,
success : function(data){
window.location.reload();
$('#cekulang').modal('show');
}
});
return false;
});


I want to open the modal after page done refreshing. but i got the modal open first then the page refreshing with that code.



Help is appreciated.


More From » ajax

 Answers
12

Try something like:



success: function(data){
window.location = window.location.href + ?openmodal=1;
}


And add in your body



<?php
if($_GET['openmodal'] == 1){ ?>
<script>
$(function(){
$('#cekulang').modal('show');
});
</script>
<?php
}
?>

[#63926] Thursday, December 24, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
reedmustafam

Total Points: 211
Total Questions: 83
Total Answers: 105

Location: Vanuatu
Member since Wed, Oct 14, 2020
4 Years ago
;