How to avoid refreshing the page in a bootstrap modal? How to avoid refreshing the page in a bootstrap modal? codeigniter codeigniter

How to avoid refreshing the page in a bootstrap modal?


You could prevent the default behavior of the button that is submitting the page.

Here is a link to the Mozilla Developer Network on "preventDefault": event.preventDefault

In jQuery you can do this like this:

$("#signin_button").on("click", function(e) {    e.preventDefault();    // the rest of your code ...});


Try changing the input type="submit" to a

<button class="btn" id="signin_button">Sign in</button> 

or

<input type="button" class="btn" id="signin_button" value="Sign in"/>

if your objective is not to submit the form.

May also be useful: Difference between <input type='button' /> and <input type='submit' />


You can use click also:

$("#signin_button").click(function (e) {  e.preventDefault();  // code}