Forums › Forums › Search & Filter Pro › Defining SF_LDATA after ajax page refresh?
- This topic has 4 replies, 2 voices, and was last updated 10 years, 5 months ago by
Ross.
-
Ross Moderator(Private) March 3, 2015 at 12:56 am #12705
Hey Sarah
This is the problem I mentioned in my other message – there appears to be some JS errors on your site and its due to (possibly) your theme.
Essentially, to pass variables from PHP into JavaScript, WordPress provides a function – wp_localize_script. This, combined with the register_script should produce markup similar to the following:
<script type='text/javascript'> /* <![CDATA[ */ var SF_LDATA = {"ajax_url":"http:\/\/yoursite.com\/wp-admin\/admin-ajax.php","home_url":"http:\/\/yoursite.com\/","sfid":"0"}; /* ]]> */ </script> <script type='text/javascript' src='http://yoursite.com/wp-content/plugins/search-filter-pro/public/assets/js/search-filter-build.js?ver=1.4.0'></script>
So our JavaScript has an object (
SF_LDATA
) with a bunch of variables stored in which are required for the plugin to function.If you are not seeing output in your HTML, then again it seems like your theme/plugin is messing with WordPress standards and not allowing this plugin (and potentially others) to load their scripts properly.
I hope that makes sense!
Thanks
Anonymous(Private) March 4, 2015 at 12:49 pm #12816Further to my previous post adding
wp_enqueue_script( 'search-filter-plugin-build' );
to my child theme functions and then using $getScript in my ajax page loading script to reload the script after the page call seems to get it working.
So I’ve managed to poke around and fix it myself. 🙂
If anyone anticipates any problem doing it this way, I’d be grateful for any advice.
Ross Moderator(Private) March 6, 2015 at 2:34 am #12909Hey Sarah
Thanks for your persistence and updates! I’ll get back to your points shortly I’m just trying to get an update of S&F out of the door urgently! 🙂
Thanks
-
AuthorPosts