Potheek Potheek - 1 month ago 9
Ajax Question

Add AJAX loader gif in prestashop

I have two questions regarding prestashop.

1) How do I add an ajax loader image in prestashop for an ajax call?

2) Can I add an AJAX loader image to every ajax call in prestashop by placing some code in one place?

I am new to prestashop, so pardon my naive question if it is.

Answer

You can add this script which will listen to all AJAX calls

//listen to ajax start event
$( document ).ajaxStart(function() {
  $('#my_loader').fadeIn();
});

//listen to ajax complete event
$( document ).ajaxComplete(function() {
  $('#my_loader').fadeOut();
});

You loader html should be something like this

<img id="my_loader" src="..." />