New answers tagged wp-register-script
JS variables are not directly replaced as you are expecting. Localizing in your code is correct. When you do var jsonPath = itajax.ajaxurl;, value of itajax.ajaxurl is assigned to the variable jsonPath. If you debug this variable in the console, you will get the correct value. console.log(jsonPath);
I found an other way that works well for me: When initializing the plugin, do not enqueue your scripts and styles, but register them with wp_register_style and wp_register_script. Next you can load the script/style on demand. For example when you render a shortcode with wp_enqueue_style("your_style") and wp_enqueue_script("your_script"). This way the ...
Top 50 recent answers are included