Posted By

dropthenerd on 01/27/11


Tagged

ajax jquery fancybox


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

luman
virendrakryadav
wirenaught
Balamir


Close a fancybox when you submit a form with ajax


 / Published in: jQuery
 

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

  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. });

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: kmcbride on January 5, 2012

Would you be able to show me the validation side? when you post the data to the validation data page how does it send the data back to ajax?

You need to login to post a comment.