Facebox window closes after submit
I have a question regarding Facebox. When I click a certain link on my page, the Facebox modal window opens just fine. But inside this modal window I'd like to have a form that users can submit. When the users click the submit-button, the whole page refreshes, and my Facebox-window is closed. This makes sense to me, but I'd like it to work differently.
I want to give the user a confirmation, inside of the modal window, after they have submitted the form. So when a user clicks the submit-button, a confirmation should be showed inside og the modal-window. Anybody开发者_StackOverflow中文版 know if this is possible?
I hope that you understand my question :)
Best regards
Kim Andersen
You need to change your form to use AJAX POST instead of standard HTML POST request. Here's a simple tutorial that shows how to do AJAX form with jQuery.
<form action='whateveryouhave.php' method='POST' id='myform' ><!--notice the form id-->
<!-- your input and form stuff here just as you have it-->
<a href='javascript:void(0);' onclick="submitFacebox">
Submit in facebox instead of whole window
</a>
<script type='text/javascript'>
function submitFacebox() {
jQuery.post(jQuery('#myform').attr('action'), jQuery('#myform').serialize());
}
</script>
精彩评论