0
A
回答
0
我试图找出你的意思 - 我觉得基本上你想要某种方式挂接到一个电话,通话结束的开始(加载和卸载微调)?更系统首先用作一次性(第一实例),然后(第二个例子) -
我在两种不同的方法做到了这一点。希望其中之一将成为你所需要的。
$.connection.myHub.server.hubMethod().done(function() {
//called on success
}).fail(function (e) {
//called on failure - I don't recommend reading e
}).always(function() {
//called regardless
spinner.close();
});
spinner.open(); // must be triggerd AFTER call incase exception thrown (due to connection not being up yet)
如果你不喜欢这样 - 也许是因为你打电话枢纽方法在数百码的不同部分,然后有其他的技巧这是更复杂一点。让我们看到:
function SetupSpinnerOnCallToSignalrMethod(hubServer, method, spinnerStartCallback, spinnerEndCallback) {
var prevFunc = hubServer[method];
hubServer[method] = function() {
var ret = prevFunc.apply(this, arguments);
spinnerStartCallback(); // must be triggerd AFTER call incase exception thrown (due to connection not being up yet)
ret.always(function() {
spinnerEndCallback();
});
return ret;
};
}
//then call this for each method
SetupSpinnerOnCallToSignalrMethod($.connection.myHub.server,
"hubMethod",
function() { spinner.open(); },
function() { spinner.close(); }
);
//the server call should then work exactly as before, but the spinner open and close calls are invoked each time.
相关问题
- 1. 从浏览器到另一台服务器的HTTP POST请求
- 2. 浏览器在请求时如何知道发送给服务器的cookie?
- 3. 服务器可以请求客户端的浏览器?
- 4. 来自浏览器或服务器的请求URL
- 5. 拦截浏览器请求并修改服务器响应
- 6. 同一浏览器对Internet服务器的多个请求
- 7. Webpack和节点服务器跨浏览器请求
- 8. 浏览器向服务器传递请求延迟
- 9. 服务器到服务器请求没有服务帐户
- 10. 浏览器和Web服务器通讯
- 11. 通过服务器打开浏览器
- 12. 关闭浏览器时如何保持Apache服务器满足请求?
- 13. 通知客户端浏览器服务器上的更改
- 14. 使用PHP从服务器端浏览器通知
- 15. 通知浏览器服务器上的事件
- 16. 为什么浏览器请求不通过我的代理服务器?
- 17. HTTP请求的浏览器
- 18. 取消请求浏览器
- 19. 停止浏览器请求
- 20. iOS浏览器请求UID使用推送通知?
- 21. 如果浏览器关闭,请执行所有ajax请求
- 22. 在浏览器中观看SignalR请求和响应
- 23. 服务器端浏览器
- 24. 客户端(浏览器)如何生成发送到服务器的请求?
- 25. 当连接到服务器时,浏览器是否自动请求index.html?
- 26. SNS通知浏览器
- 27. 通过请求请求的HTML内容与浏览器不同
- 28. 从服务器到客户端的SignalR通知
- 29. 服务与快递编译玉时浏览器请求“element.html”
- 30. RestEasy的服务返回的浏览器请求和