Close a fancybox ON form submit and BEFORE processing with ajax.


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $("#MyForm").live('submit',function(){
  2. var params = $(this).serialize();
  3. var self = this;
  4.  
  5. $.ajax({
  6. type: 'POST',
  7. url: self.action,
  8. data: params,
  9. beforeSend: function(){
  10. alert('Closing');
  11. $.fancybox.close();
  12. },
  13. success: function(data){
  14. alert('Finished processing form');
  15. return false;
  16. },
  17. dataType: 'json'
  18. });
  19.  
  20. return false;
  21. });
  22. }

URL: http://www.dropthenerd.com/close-fancybox-on-form-submit-but-before-processing-via-ajax/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.