Cimy Riya Cimy Riya -4 years ago 79
jQuery Question

after showing bootstrap modal from the sucess function of ajax, after a particular time call a javascript function

//ajax function call success function in an external javascript file

success: function(data) {
$('#edtModal').show();
}


//at jsp page

$('#edtModal').on('shown.bs.modal', function() {
alert("hi");
var ex = getTime('tt');
window.setTimeout(alertFunc, ex);
});


//but the above jquery code in jsp not working

Answer Source

//at jsp page //when below button is clicked

<a class="btn btn-default btn-sm btn-primary edt" title="Edit" onclick="setValues('${row.a}', '${row.b}', '${row.C}', '${row.d}')"  role="button"><span class="glyphicon glyphicon-edit"></span></a>    

//it will set values onclick and call a ajax function and the sucess function of //ajax shows a modal

success: function(data) {
                $('#edtModal').show();
           }

//in jsp when button is clicked the bellow jquery also works but it shows only //if ajax is sucess,so it works like shown.bs.modal

 $('.edt').click(function() {

                        var ex = countDown('xxx');
                        setTimeout(function alertFunc() {
                            var r = confirm("Your Time Expired,Do you want to continue");
                            if (r === true) {
                                window.setTimeout(alertFunc, ex);
                            } else {
                                var url = "hide";
                                window.location = url;
                            }
                        }, ex);
                    });
                });
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download