Title: Adding jQuery
Last modified: August 24, 2016

---

# Adding jQuery

 *  Resolved [BBIndikator](https://wordpress.org/support/users/bbindikator/)
 * (@bbindikator)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-2/)
 * Hey there..!
 * Really nice plugin, thanks for sharing it !
 * As you know, the less inline – the better..
 * Please check this out : )
 * Thank you and best regards
 * PHP Part inside your ajax.php
 *     ```
       // Enqueue Script for Newsletter
       if ( ! function_exists( 'epm_mailchimp_footer_js' ) )
       {
       	add_action( 'wp_enqueue_scripts', 'epm_mailchimp_footer_js' );
       	function epm_mailchimp_footer_js()
       	{
       		wp_enqueue_script('newsletter-script', get_stylesheet_directory_uri() . '/js/newsletter.js', array('jquery'),'1.0', true);
       		wp_localize_script('newsletter-script', 'epNewsletterVars', array(
       				'ajaxURI' => admin_url('admin-ajax.php'),
       				'successEvent' => do_action('epm_jquery_ajax_success_event')
       			)
       		);
       	}
       }
       ```
   
 * jQuery-Part inside childthemes js folder
 *     ```
       jQuery(window).load(function() {
       	jQuery('.epm-submit-chimp').click(function() {
       alert(bbNewsletterVars.ajaxURI);
       		//get form values
       		var epm_form = jQuery(this);
       		var epm_list_id = jQuery(epm_form).parent().find('#epm_list_id').val();
       		var epm_firstname = jQuery(epm_form).parent().find('#epm-first-name').val();
       		var epm_lastname = jQuery(epm_form).parent().find('#epm-last-name').val();
       		var epm_email = jQuery(epm_form).parent().find('#epm-email').val();
   
       		//change submit button text
       		var submit_wait_text = jQuery(this).data('wait-text');
       		var submit_orig_text = jQuery(this).val();
       		jQuery(this).val(submit_wait_text);
   
       		jQuery.ajax({
       			type: 'POST',
       			context: this,
       			url: epNewsletterVars.ajaxURI,
       			data: {
       				action: 'epm_mailchimp_submit_to_list',
       				epm_list_id: epm_list_id,
       				epm_firstname: epm_firstname,
       				epm_lastname: epm_lastname,
       				epm_email: epm_email
       			},
       			success: function(data, textStatus, XMLHttpRequest){
       				var epm_ajax_response = jQuery(data);
       				jQuery(epm_form).parent().find('.epm-message').remove(); // remove existing messages on re-submission
       				jQuery(epm_form).parent().prepend(epm_ajax_response);
       				jQuery(epm_form).val(submit_orig_text); // restore submit button text
       				epNewsletterVars.successEvent;
       			},
       			error: function(XMLHttpRequest, textStatus, errorThrown){
       				alert('Something Went Wrong!');
       			}
       		});
       		return false;
   
       	});
       });
       ```
   
 * [https://wordpress.org/plugins/easy-peasy-mailchimp-ajax-form/](https://wordpress.org/plugins/easy-peasy-mailchimp-ajax-form/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [BBIndikator](https://wordpress.org/support/users/bbindikator/)
 * (@bbindikator)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-2/#post-6068202)
 * Resolved : )

Viewing 1 replies (of 1 total)

The topic ‘Adding jQuery’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/easy-peasy-mailchimp-ajax-form_9d7e60.
   svg)
 * [Easy Peasy MailChimp Ajax Form](https://wordpress.org/plugins/easy-peasy-mailchimp-ajax-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/easy-peasy-mailchimp-ajax-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/easy-peasy-mailchimp-ajax-form/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-peasy-mailchimp-ajax-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-peasy-mailchimp-ajax-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-peasy-mailchimp-ajax-form/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [BBIndikator](https://wordpress.org/support/users/bbindikator/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-2/#post-6068202)
 * Status: resolved