Forums Forums Search & Filter Pro Defining SF_LDATA after ajax page refresh?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Ross Moderator
    #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
    #12741
    This reply has been marked as private.
    Anonymous
    #12816

    Further 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
    #12909

    Hey 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

Viewing 4 posts - 1 through 4 (of 4 total)