jquery - Submit button closes fancy box -
i have form display inside of fancybox modal. using jquery , ajax submit form. reason, when hit submit, fancybox modal closes. form gets submitted via jquery , ajax fine. problem because if there errors, supposed displayed inside of modal. can stop closing upon submit?
my jquery , ajax:
$("#change-pass").submit(function() { var datastring = $(this).serialize(); var $this = $(this); $.ajax({ type: "post", url: "change_password.php", data: datastring, success: function(html) { $this.parent().find('.tutorial-text').html(html); } }); return false; });
thanks!
since using ajax, may need fancybox errors. add error
handler ajax call :
$("#change-pass").submit(function() { var datastring = $(this).serialize(); var $this = $(this); $.ajax({ type: "post", url: "change_password.php", data: datastring, success: function(html) { $this.parent().find('.tutorial-text').html(html); }, error : function(html){ var errormsg = // build error msg here $.fancybox.open(errormsg, { // api options }) } }); return false; });
Comments
Post a Comment