本文介绍了如何在Rails UJS中设置超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
新颖而酷的语法使我可以编写:
The new and cool syntax allows me to write:
link_to some_path, :remote => true生成AJAX请求.但是,如果我需要更长的超时时间(例如100000ms),该在哪里设置呢?我阅读了 link_to ,但一无所获.
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.
推荐答案您可以使用jquery-ujs中的 $.rails.ajax 属性来注入超时(如果尚未显式传递超时):
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); }; // ... });更多推荐
如何在Rails UJS中设置超时?
发布评论