开发者

problem with jquery form plugin

I have Jquery Form plugin but i do not have submit button in my form ? i have a checkbox and on its click i submit the form . The form gets submitted but without the ajax . I am wondaring if it is possible to use jquery form plugin with out a submit button in it. ?

This is the code i am using for submitting the jquery form plugin using checkbox onlclick event. Every thing works fine without the onclick event.

$('#anl_popup').hide();
var options = { success: showResponse  // post-submit callback };

$('#favourite_form').submit(function() {
    $(this).ajaxSubmit(options);
    return false;
});

$('#remember_checkbox').click(function() {
    document.favourite_form.开发者_JS百科submit();
    return false;
});


Yes, you can submit your form without a submit button. I would suggest to write it like this:

$(function() {
   $('#favourite_form').ajaxForm({ success: showResponse });
   $('#remember_checkbox').click(function() {
       this.form.submit();
   });
});
function showResponse(responseText, statusText, xhr, $form)  { 
    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
        '\n\nThe output div should have already been updated with the responseText.'); 
} 

That should be enough.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜