Close a fancybox when you submit a form with ajax


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



Copy this code and paste it in your HTML
  1. $('#ajaxForm').submit(function(){
  2. var params = $(this).serialize();
  3. var self = this;
  4.  
  5. $.post(
  6. '/ajax.php',
  7. params,
  8. function(data){
  9. switch(data.status){
  10. case 1: //success
  11. $.fancybox.close();
  12. break;
  13.  
  14. case 0: //failure
  15. console.log(data);
  16. $('#errorMessage').html(data.message);
  17. break;
  18.  
  19.  
  20. }
  21. },
  22. 'json'
  23. );
  24.  
  25. return false;
  26.  
  27. });

URL: http://www.dropthenerd.com/close-fancybox-when-you-submit-a-form-revisited

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.