This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Delay javascript loading of AJAX results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Delay javascript loading of AJAX results Reply To: Delay javascript loading of AJAX results

#20890
Ernest MarcinkoErnest Marcinko
Keymaster

Hi!

That could be possible to achieve with a small custom code snippet, I believe. So instead of enabling the auto populate feature, you can trigger the search via the javascript API whenever you need it.

In your case you could try something like:

add_action('wp_footer', 'asp_add_footer_action');
function asp_add_footer_action() {
  ?>
  <script>
  jQuery(function($){
    setTimeout(function(){
      // Run the search, delayed after 2 seconds
      ASP.api(1, 'searchFor', '');
    }, 2000);
  });
  </script>
  <?php
}

This will add a script to the site footer to execute an empty search (basically auto-populate) manually after 2 seconds.
I hope this helps!