Reputation: 815
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.
Upvotes: 1
Views: 17329
Reputation: 1031
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
}
?>
Upvotes: 7