简体   繁体   English

动画没有显示在Ace中的Ajax请求

[英]Animation not showing when ajax request in pace.js

In my website http://www.eventiame.com/publicar/ there's a form with several fields. 在我的网站http://www.eventiame.com/publicar/中,有一个包含多个字段的表格。 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. 当页面加载时,它显示速度动画(加载时它会执行一些ajax请求,这样就可以了),但是当我提交表单(我也通过ajax来执行)时,动画不会出现。 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. 我也尝试在akax请求中将“ async”参数更改为true或false,但仍然没有效果。

Here's the specific code for the ajax call which is not working: 这是无法正常使用的ajax调用的特定代码:

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

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. 默认情况下,Pace将显示所有以正常或ajax-y页面加载的一部分开始或持续时间超过500ms的ajax请求。 your ajax request didnt trigger the pace because it's too soon. 您的ajax请求没有触发速度,因为它太早了。

1, Modify the Pace.js : 1,修改Pace.js:

Find restartOnRequestAfter under the defaultOptions and change it to desire time (in milliseconds) value 5 ms. defaultOptions下找到restartOnRequestAfter ,并将其更改为所需的时间(以毫秒为单位)值5 ms。

  restartOnRequestAfter: 5,

2, Tracking: 2,跟踪:

By default, Pace will only track GET HTTP method, so add all other method you might need such as POST request. 默认情况下,Pace仅跟踪GET HTTP方法,因此添加您可能需要的所有其他方法,例如POST请求。

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

SOURCE: http://github.hubspot.com/pace/ 消息来源: http //github.hubspot.com/pace/

You may try this: 您可以尝试以下方法:

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

I had this same problem and I found a solution in Pace issues section. 我遇到了同样的问题,并且在“ Pace问题”部分找到了解决方案。 Source 资源

You have a missing closing single quote, should be: 您缺少结束的单引号,应为:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM