geogrow geogrow - 1 year ago 89
jQuery Question

Action on submit

I have beginner question about submit behavior. Every time I press submit my loginModal keep coming back up, is this expected behavior? Its like the ready() function is fired again. I would like my initiate App() function to be executed after submit

Here is bits of my code:

//Show loginModal on page ready

//loginModal submit
<div class="modal-footer">
<button type="submit" class="btn btn-danger btn-default pull-left" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>`enter code here`

//When submit button is clicked
$('#loginModal').submit(function() {}


Answer Source

You need to prevent the default behviour of the submit button i.e. to refresh the page. Use event.preventDefault()

$('#loginModal').submit(function(event) {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download