Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Delay javascript loading of AJAX results
This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko 4 years, 4 months ago.
- AuthorPosts
- January 22, 2019 at 2:57 am #20882
Hi there, I have some asynchronous authentication in Javascript that takes about 2 seconds to finish, and it needs to be done BEFORE the AJAX results start rendering. I’d like to block the results from loading until then. I understand it may be hard to connect the results to a callback, but is there a simple way to add a settimeout somewhere so that the results are delayed by 2 seconds? Even if it’s inaccurate? I’m not sure where in the javascript of the plugin to even begin looking for this functionality.
Thanks for any help!
January 22, 2019 at 11:27 am #20890Hi!
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.
Best,
I hope this helps!
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.