I am developing a webpage using jquery and I have a contact form in a div which is opening using slide toggle function, problem is, when I submit the form page is refreshing and form is getting closed, how to stop close the forms div and how to submit the form without refreshing the page.
Share
You should handle the submit process with the client-side events and then “return false;” for the button so that the form will not be refreshed.
Or as an alternative, you can use an image for the submit button (which will not refresh the page on a click) and again you can simply put the submit javascript function on this image’s onclick event.
For the submit function you can see the reference and examples of .ajax() function here:
http://api.jquery.com/jQuery.ajax/
If you do this part correctly, your first problem will be solved. If the page does not refresh, then there will be no problem of closing divs 😉