All Questions
Tagged with wp-localize-script theme-development
6 questions
0
votes
1
answer
146
views
Localize script not working in ajax
I'm getting the error "Uncaught ReferenceError: WPURLS is not defined" when I try to use ajax. Have I done something wrong here? Running the localize script after the script.min.js file, is ...
0
votes
0
answers
99
views
How to echo inside the js file with wp_localize_script?
I have used wp_localize_script() to pass a variable to a javascript file.
var countries = [searchresults.data];
The variable is getting passed but I want it in a js file like below:
var countries = ...
2
votes
2
answers
9k
views
How to Globally Use wp_localize_script() Ajax URL
I have added this to my functions.php and need to use ajaxURL in all of enqueued scripts in the template (instead of enqueuing only one script here
add_action( 'wp_enqueue_scripts', '...
0
votes
1
answer
2k
views
Update Data parameter of a wp_localize_script() call
I'm working on a child theme, In my-page-template.php I have :
//...
$current_key= 5; //calculated result
wp_localize_script('my_js', 'ajaxload', array('post_id' => $current_key));
In my_js.js I ...
2
votes
2
answers
1k
views
WP_LOCALIZE_SCRIPT doesn't work
I am creating AJAX loading and need to use WP_LOCALIZE_SCRIPT but cannot make it work.
Here is my code. I place it in functions.php
wp_enqueue_script( 'page_data');
$gallery_js_data_array = array(
...
0
votes
0
answers
218
views
Passing a location-dependent array via wp_localize_script within a shortcode
I have created a shortcode that is intended to be inserted into custom field of a music custom post type. The shortcode is coverted into an audio playlist using the jplayer jquery plugin (and it's ...