epm_mailchimp_footer_js

Add js ajax script to footer.

Description

epm_mailchimp_footer_js(); 

Usage

  1. if ( !function_exists( 'epm_mailchimp_footer_js' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'easy-peasy-mailchimp-ajax-form/includes/ajax.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = epm_mailchimp_footer_js(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/ajax.php  
  1. function epm_mailchimp_footer_js() { ?> 
  2. <script> 
  3. jQuery(window).load(function() { 
  4. jQuery('.epm-submit-chimp').click(function() { 
  5.  
  6. //get form values 
  7. var epm_form = jQuery(this); 
  8. var epm_list_id = jQuery(epm_form).parent().find('#epm_list_id').val(); 
  9. var epm_firstname = jQuery(epm_form).parent().find('#epm-first-name').val(); 
  10. var epm_lastname = jQuery(epm_form).parent().find('#epm-last-name').val(); 
  11. var epm_email = jQuery(epm_form).parent().find('#epm-email').val(); 
  12.  
  13. //change submit button text 
  14. var submit_wait_text = jQuery(this).data('wait-text'); 
  15. var submit_orig_text = jQuery(this).val(); 
  16. jQuery(this).val(submit_wait_text); 
  17.  
  18. jQuery.ajax({ 
  19. type: 'POST',  
  20. context: this,  
  21. url: "<?php echo admin_url('admin-ajax.php');?>",  
  22. data: { 
  23. epm_list_id: epm_list_id,  
  24. epm_firstname: epm_firstname,  
  25. epm_lastname: epm_lastname,  
  26. epm_email: epm_email 
  27. },  
  28. success: function(data, textStatus, XMLHttpRequest) { 
  29. var epm_ajax_response = jQuery(data); 
  30. jQuery(epm_form).parent().find('.epm-message').remove(); // remove existing messages on re-submission 
  31. jQuery(epm_form).parent().prepend(epm_ajax_response); 
  32. jQuery(epm_form).val(submit_orig_text); // restore submit button text 
  33. <?php do_action('epm_jquery_ajax_success_event');?> 
  34. },  
  35. error function(XMLHttpRequest, textStatus, errorThrown) { 
  36. alert('Something Went Wrong!'); 
  37. }); 
  38. return false; 
  39.  
  40. }); 
  41. }); 
  42. </script> 
  43. <?php }