Title: wp_localize_script() call inside Events
Last modified: June 2, 2020

---

# wp_localize_script() call inside Events

 *  Resolved [Michael Finkenberger](https://wordpress.org/support/users/mitfi/)
 * (@mitfi)
 * [6 years ago](https://wordpress.org/support/topic/wp_localize_script-call-inside-events/)
 * Dear support team,
 * I am a happy user of the Events Manager plugin.
 * On some of my pages, I use jQuery.ajax in order to update only part of the page’s
   content.
 * In order to link js-variables with content defined by PHP, I am using the wp_localize_script()
   function, which works perfectly.
 * However, when trying to use this inside an Event, the jQuery.ajax call will fail,
   because the js-variable remains undefined. This could mean that the wp_localize_script()
   function seems not to having been called.
 * Below you will find the related code.
    Trying to move the function to the footer(
   last Boolean in wp_register_script() and wp_enqueue_script() = true) failed as
   well.
 * Thank you very much for your help in advance!
 * Michael
 * function mf_sw_voodle_sort_hook_ajax_script() {
    $js_url = “/wp-content/themes/
   pure-simple-child/js/”; wp_register_script( ‘mf_sw_voodle_sort_ajax_script’, 
   $js_url.’mf_sw_voodle_sort_ajax_file.js?V1.1.53′, array(‘jquery’), false, false);
   wp_enqueue_script( ‘mf_sw_voodle_sort_ajax_script’, $js_url.’mf_sw_voodle_sort_ajax_file.
   js?V1.1.53′, array(‘jquery’), false, false );
 *  wp_localize_script( ‘mf_sw_voodle_sort_ajax_script’, ‘mf_sw_voodle_sort_var’,
   array(
    ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ), ‘title’ => get_the_title()));}
   add_action( ‘wp_enqueue_scripts’, ‘mf_sw_voodle_sort_hook_ajax_script’ ); add_action(‘
   admin_enqueue_scripts’, ‘mf_sw_voodle_sort_hook_ajax_script’ );

Viewing 1 replies (of 1 total)

 *  Thread Starter [Michael Finkenberger](https://wordpress.org/support/users/mitfi/)
 * (@mitfi)
 * [6 years ago](https://wordpress.org/support/topic/wp_localize_script-call-inside-events/#post-12927028)
 * Dear all,
 * The topic is solved as there was an issue generated by another plugin.
 * Best regards
 * Michael

Viewing 1 replies (of 1 total)

The topic ‘wp_localize_script() call inside Events’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Michael Finkenberger](https://wordpress.org/support/users/mitfi/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/wp_localize_script-call-inside-events/#post-12927028)
 * Status: resolved