Tag: 超时

为控制器操作设置超时

我已经遇到过这个post ,但我可能还需要其他一些东西来解决我的问题。 我有一个返回ViewResult的动作,该动作由客户端的$.post()调用 JavaScript的: var link = ‘GetFoo?fooBar=’ + fooBar; var jqxhr = $.post(link, function (response) { $(‘#myDiv’).replaceWith(response); }); 控制器: public ViewResult GetFoo(String fooBar) { if (Request.IsAjaxRequest()) { // perform a ridiculously long task (~12 minutes) // algorithm: 1) download files from the Azure blob storage // 2) update each file // 3) reupload to […]

如何取消jquery.load()?

当load()在5秒内没有返回时,我想取消.load()操作。 如果是这样,我会显示一条错误消息,例如’抱歉,没有图片加载’。 我拥有的是…… …超时处理: jQuery.fn.idle = function(time, postFunction){ var i = $(this); i.queue(function(){ setTimeout(function(){ i.dequeue(); postFunction(); }, time); }); return $(this); }; …初始化错误消息超时: var hasImage = false; $(‘#errorMessage’) .idle(5000, function() { if(!hasImage) { // 1. cancel .load() // 2. show error message } }); …图像加载: $(‘#myImage’) .attr(‘src’, ‘/url/anypath/image.png’) .load(function(){ hasImage = true; // do something… […]