how to set timeout in rails UJS?

末鹿安然 提交于 2019-12-23 12:11:16

问题


The new and cool syntax allows me to write:

link_to some_path, :remote => true

to generate an AJAX request. But if I need longer timeout(e.g. 100000ms), where can I set it? I read link_to but found nothing.


回答1:


You can use $.rails.ajax property from jquery-ujs, to inject the timeout if it has not been passed explicitly:

$(function() {
    // ...

    $.rails.ajax = function(options) {
      if (!options.timeout) {
        options.timeout = 100000;
      }      
      return $.ajax(options);
    };

    // ...
});


来源:https://stackoverflow.com/questions/7694465/how-to-set-timeout-in-rails-ujs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!