开发者

Form wrapped in jQuery causing some issues

I have a form wrapped in jQuery. It slideToggles on click of a div. 开发者_如何转开发This form is self submitting. So when I display any errors / confirmation on submit of the form, they'll be encapsulated within the jQuery / div. On the page reload the jQuery hides the form disallowing the user to see the errors / confirmation unless they reopen the contact form. Now, I clearly am unhappy with that. What would be a work around this. I haven't jumped to much into AJAX as of yet. Would this be my only option here? And if so, what would be some basic code or a good starting ground to solve this? Thank you.

Here is the jQuery for when a user clicks the contact div, and below merely represents that it is a self submitting form.

$(document).ready(function() {
        $('#box').hide();
        $('#contact_link_contact').click(function() {
            $('#box').slideToggle(1500);
            });
        });

<form action="" method="post">


Try this:

$( form ).submit( function() {
    $.ajax() // send data here
    return false;
});

This will prevent the page from reloading when you submit the form, but you will need to send the data using ajax.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜