Jaax-jquery Status "processing" for Pace.js bar

0

I'm using pace.js (which is like the top loading bar from youtube) for the loading bar on my web page, and to detect the ajax requests I use:

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

Which executes the pause bar when the request starts, but obviously the start delay takes less time than processing the request and causes the bar to be animated but the animation ends before the request is executed completely.

Maybe they do not know pace, so my question may also be, what event did I capture so that the animation matches the total duration of the jquery's Ajax request ?, thanks

    
asked by Andress Blend 03.02.2017 в 19:54
source

1 answer

1

I already found the answer, I leave it in case someone has the same question

You have to enclose the ajax in Pace.track , like this:

Pace.track(function() {
  $.ajax({
    data: {
      "data": formData
    },
    type: "POST",
    url: "inc/sendmail.php",
    success: function(data) {
      //succes
    }
  });
});
    
answered by 03.02.2017 в 19:57