pace icon indicating copy to clipboard operation
pace copied to clipboard

AJAX Requests don't Trigger Pace

Open martincarlin87 opened this issue 12 years ago • 26 comments

I've just 'installed' Pace into my app and it works perfectly on the main page load but on any subsequent AJAX requests that occur after the initial page load the animation doesn't trigger when I believe Pace should handle these automatically?

From reading the docs I think I can manually trigger and stop Pace by doing

Pace.start // Pace.restart ?
$.ajax({    
    success: function(data) {
        Pace.stop
    }
});

or even wrap the AJAX requests like so:

Pace.track(function(){
    $.ajax(...)
});

but I have a load of requests throughout my app and trying to avoid having to go back and change them all.

I've simply included Pace in my page like so

<!-- pace.js -->
<script type="text/javascript" src="/plugins/pace/pace.js"></script>
<link href="/plugins/pace/pace.css" rel="stylesheet" type="text/css"/>

with no options set etc.

Should've mentioned I'm using jQuery but I've just read through all the previously closed issues and found the answer:

$(document).ajaxStart(function() { Pace.restart(); });

martincarlin87 avatar Apr 02 '14 13:04 martincarlin87

You just saved at least an hour of mine, you're awesome!

steelbrain avatar Aug 27 '14 10:08 steelbrain

glad it helped, the answer was there but just buried away in a closed issue.

martincarlin87 avatar Sep 11 '14 10:09 martincarlin87

Saved me a lot of time! Thank you!

ChengJoyceJi avatar Jul 07 '15 15:07 ChengJoyceJi

Thank you!

AmiraNasrullah avatar Jul 10 '15 11:07 AmiraNasrullah

Thank you for this answer! I've been struggleing with this for about an hour already.

Shouldn't this be added to the official docs? Or in a FAQ?

cristianuibar avatar Jul 31 '15 12:07 cristianuibar

thanks, man. They really should make limit of ajax responce as an option. Now it's 500ms.

molod avatar Sep 25 '15 10:09 molod

Thank you!

nullifiedaccount3 avatar Sep 27 '15 07:09 nullifiedaccount3

Thank you! great job man

Arkone avatar Dec 09 '15 14:12 Arkone

Thanks a ton...dude...RESPECT

ankurksoni avatar Mar 20 '16 07:03 ankurksoni

Tks!!!! Save my day!!!

andreferraro avatar Jun 07 '16 18:06 andreferraro

Thanks.

singhimalaya avatar Jun 15 '16 01:06 singhimalaya

About an hour looking for an answer that could fix it, and Here is it! Thanks man, more people like you on earth, please lol.

JuanModesto avatar Sep 15 '16 18:09 JuanModesto

It was a good catch! Thank you! Since pace is loaded at the beginning of the project, much ahead than the jQuery, it was not able to recognize the jquery ajaxStart event. Adding pace to the ajaxStart listener solves the issue.

snarun avatar Nov 04 '16 13:11 snarun

Thanks.

izhangzhihao avatar Nov 26 '16 02:11 izhangzhihao

Thanks martincarlin87... it's worked !!!

ghost avatar Jan 09 '17 11:01 ghost

Give this man a Cookie! Thanks.

him-developer avatar Feb 28 '17 13:02 him-developer

Thank youuuuuuu

Sau64 avatar May 04 '17 03:05 Sau64

感谢老哥

xibudu avatar Jun 08 '17 04:06 xibudu

非常感谢

the94air avatar Aug 13 '17 20:08 the94air

@martincarlin87 this shows the loader when the resquest is called, but doesn't wait the response to hide the loader. Anyone having the same issue?

aline-matos avatar Aug 30 '17 01:08 aline-matos