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
January 22, 2019 at 11:27 am
#20890
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!