• Resolved Michael

    (@mitfi)


    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

    (@mitfi)

    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.