I\'ve recently been fiddling around with twitter bootstrap, using java/jboss, and i\'ve been attempting to submit a form from a Modal interface, the form contains just a hid
Old, but maybe useful for readers to have a full example of how use modal.
I do like following ( working example jsfiddle ) :
$('button.btn.btn-success').click(function(event)
{
event.preventDefault();
$.post('getpostcodescript.php', $('form').serialize(), function(data, status, xhr)
{
// do something here with response;
console.info(data);
console.info(status);
console.info(xhr);
})
.done(function() {
// do something here if done ;
alert( "saved" );
})
.fail(function() {
// do something here if there is an error ;
alert( "error" );
})
.always(function() {
// maybe the good state to close the modal
alert( "finished" );
// Set a timeout to hide the element again
setTimeout(function(){
$("#myModal").hide();
}, 3000);
});
});
To deal easier with modals, I recommend using eModal, which permit to go faster on base use of bootstrap 3 modals.