admin管理员组

文章数量:1287511

In my website / there's a form with several fields. When the page loads it shows the pace animation (it does some ajax request when loading so that's ok) but when I submit the form (I do it via ajax too) the animation doesn't appear. I tested uploading an image (so it would take longer) and still no animation is shown. I also tried changing the "async" parameter to true or false in the akax request but still no good.

Here's the specific code for the ajax call which is not working:

$.post('Sample.php,$(this).serialize(),function(data){
    $(target).html(data);
},'html');

In my website http://www.eventiame./publicar/ there's a form with several fields. When the page loads it shows the pace animation (it does some ajax request when loading so that's ok) but when I submit the form (I do it via ajax too) the animation doesn't appear. I tested uploading an image (so it would take longer) and still no animation is shown. I also tried changing the "async" parameter to true or false in the akax request but still no good.

Here's the specific code for the ajax call which is not working:

$.post('Sample.php,$(this).serialize(),function(data){
    $(target).html(data);
},'html');
Share Improve this question edited Jan 9, 2015 at 0:31 JasonMArcher 15k22 gold badges59 silver badges53 bronze badges asked Dec 21, 2014 at 15:07 AliNasiriAliNasiri 1371 gold badge3 silver badges12 bronze badges 3
  • 2 Typo? Shouldn't it be 'sample.php'? – Christian Gollhardt Commented Dec 21, 2014 at 15:17
  • it is not work with $.post or $.ajax() – AliNasiri Commented Dec 21, 2014 at 15:19
  • same here it does not accept post request but it accept get request :) – Kavin Commented Jan 19, 2015 at 12:03
Add a ment  | 

3 Answers 3

Reset to default 6

I hope my answer is not too late, but in case of those that might still need it, i had thesame issue also and i solved it.

By default, Pace will show any ajax requests which begin as a part of a normal or ajax-y page load, or which last longer than 500ms. your ajax request didnt trigger the pace because it's too soon.

1, Modify the Pace.js :

Find restartOnRequestAfterunder the defaultOptionsand change it to desire time (in milliseconds) value 5 ms.

  restartOnRequestAfter: 5,

2, Tracking:

By default, Pace will only track GET HTTP method, so add all other method you might need such as POST request.

ajax: {
  trackMethods: ['GET', 'POST', 'PUT', 'DELETE', 'REMOVE'],
  ...
}

SOURCE: http://github.hubspot./pace/

You may try this:

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

I had this same problem and I found a solution in Pace issues section. Source

You have a missing closing single quote, should be:

$.post('Sample.php', $(this).serialize(), function(data){
    $(target).html(data);
}, 'html');

本文标签: javascriptAnimation not showing when ajax request in pacejsStack Overflow