Tag Info

Hot answers tagged


You use globals :( whenever you think that you need to use a global you should automatically stop coding and invest as much time as it takes to remove that need. In your case it seems like you assume that global variables persist between Ajax request, but they don't. In addition your design of the code is broken as in client server configuration you can not ...


Anyway, basically Hody_McGee gave the answer in his comment: You could use wp_localize_script(). As it states in the Codex: [wp_localize_script()] can be used to make any data available to your script that you can normally only get from the server side of WordPress. How do we do this? <?php add_action( 'wp_enqueue_scripts', 'register_scripts' ...


Instead of rolling-your-own, just use a plugin designed specifically for that purpose for the CDN in question: https://wordpress.org/plugins/use-google-libraries/


There is a way out, use complete instead of success or done posts = $.ajax({ type: 'GET', url: ajaxurl, async: false, dataType: 'json', data: { action : 'getHotelsList' }, complete: function(results) { and try to remove async:false if problem persists

Only top voted, non community-wiki answers of a minimum length are eligible