简体   繁体   English

没有为发布请求显示速度轨

[英]pace-rails not showing for post requests

I have written a custom ajax function which uses POST and I need to show the pace progress bar until the ajax stops and returns.我编写了一个使用 POST 的自定义 ajax function,我需要显示速度进度条,直到 ajax 停止并返回。 It is working fine for GET request because there is no config needed.它对于 GET 请求工作正常,因为不需要配置。 I need to know how to set a method to show the Pace on ajax calls.我需要知道如何设置一种方法来显示 ajax 调用的 Pace。

gem 'pace-rails'

Jquery for all ajax requests. Jquery 用于所有 ajax 请求。

  $(document).on({
    ajaxStart: function() { Pace.start() },
    ajaxStop: function() { Pace.stop() }
  });

By default track method is set to GET we can add additional methods using these options:默认情况下,track 方法设置为 GET,我们可以使用以下选项添加其他方法:

<script>
    window.paceOptions = {
        ajax: {
            trackMethods: ['GET', 'POST', 'PUT', 'DELETE', 'REMOVE']
        },
        restartOnRequestAfter: true
    };
</script>

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

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