Try making a simple PJAX request with beforeSend and complete attributes.
The beforeSend attribute will be executed before the HTTP request is issued . I often use it when creating a loader for a specific AJAX / PJAX event. Whenever the user fires an event (i.e. presses a button), the function assigned beforeSend hides the contents of the div that I am updating and places the gif loader there, which gives a nice user interface.
The complete attribute will be executed after loading the specified page. If I use the example that I gave with the loader, you can make the function assigned to the attribute complete , hide the image of the loader and update the div with the loaded content from the requested page.
Here is an example with a bootloader image:
$.pjax({ url: 'requested_page.php', container: '#updated_div', beforeSend: function(){ $('#loader_place').fadeIn('normal');
If you want to do something more complex, I suggest you read the PJAX Documentation .
source share