Muhammad Usman Muhammad Usman - 10 months ago 51
HTML Question

prevent page to reload jquery

The code is working fine for me if the page is completely loaded But the issue is if the page is in loading mode I click on the link it reloads again how I prevent it from reloading.

$('#myModal').on('', function (e) {
var key = $(e.relatedTarget).data('id');
type : 'post',
url : 'test.php',
data : 'key='+ key,
success : function(data) {
complete: function() {
return false;

My Html is here

<a href='' data-toggle='modal' data-target='#myModal' data-id='1:2:3:4'>UP</a>

If page is completey loaded and i click on this the ajax call is works fine but when page is loading if i clcik the page starts reloading again how i prevent it to reload.

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Check Server Status</h4>
<div class="modal-body">
<div id="loadingmessage">Checking...</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

Answer Source

<a href='#' data-toggle='modal' data-target='#myModal' data-id='1:2:3:4'>UP</a>