问题
I have a form that submits some content to a database and it works fine.
Now I want to move it to a fancybox. The problem is that when I click the submit button on the fancybox the page redirects to the actual form page instead of staying on the fancybox.
Any idea on how to stop the page from redirecting?
Thanks
回答1:
How are you loading the content into the fancybox? If you use the iframe method, it should remain within it.
See point 4 on this page to load data as an iframe http://fancybox.net/howto
EDIT
You need to put the form in a separate page and then load that page into the fancybox using the method specified. For example, if you created a new page called myform.asp which would contain your form and form. You would then create a link on your page to contain your fancybox which would call the myform.asp page in an iframe:
<a href="http://www.yourdomain.com/myform.asp" class="iframe">Fill Out Form</a>
回答2:
You could do an ajax post request.
See: http://jquery.malsup.com/form/
来源:https://stackoverflow.com/questions/4648312/fancybox-form-submit