单向操作与异步调用(One-Way operations vs Asynchronous calls)
如本文第一部分所述 (.chm文件 - 请参阅下面的注释)
单向调用不等同于异步调用。 当单向呼叫到达服务时,它们可能不会立即全部调度,并且可能在服务端排队等待一次调度一次......如果排队消息的数量超过了队列的容量,那么即使发出单向呼叫,客户端也会阻止。
如果调用单向调用,它何时将控制权返回给调用者? 同一篇文章的介绍指出单向调用用于即发即弃操作 ,从而模拟一种异步调用。 如果会话WCF服务具有启动会话的Login()单向方法,此方法何时将控制权返回给调用者? 是否在方法实际执行服务之前返回? 如果是这样,我怎么能确定该方法是在服务上执行的?
如果我希望服务返回到客户端登录过程中可能发生的错误,那么异步调用是实现“即发即弃”行为的唯一方法吗?
注意:上面引用的文章来自一篇名为WCF Essentials的文章- 你需要了解的关于单向调用,回调和事件的内容由Juval Lowy提供,可以在2006年10月的MSDN杂志中找到。 上面的链接是MSDN上的帮助文件(.chm)格式。 如果您无法使链接的CHM文件起作用(我不能),您可以使用7zip打开它。
As stated in the first section of this article (.chm file - see note below)
One-way calls do not equate to asynchronous calls. When one-way calls reach the service, they may not be dispatched all at once and may be queued up on the service side to be dispatched one at a time... If the number of queued messages has exceeded the queue's capacity, then the client will block, even when issuing a one-way call.
If a one-way call is invoked, when does it return control to the caller? The introduction of the same article states that one-way calls are used for fire-and-forget operations, thereby simulating a kind of asynchronous call. If a sessionful WCF service has a Login() one-way method which starts the session, when does this method return control to the caller? Does it return before the method is actually executed on the service? If so, how can I be sure that the method was performed on service?
If I wanted the service to return to the client the possible errors that occur during the login procedure, would be an asynchronous call the only way to achieve a fire-and-forget behaviour?
Note: The quote above is taken from an article called WCF Essentials - What You Need To Know About One-Way Calls, Callbacks, And Events by Juval Lowy, and can be found in the October 2006 issue of MSDN magazine. The link above is to a help file (.chm) format on MSDN. If you can't get the linked CHM file to work (I couldn't) you can open it with 7zip.
原文:https://stackoverflow.com/questions/12112926
最满意答案
load()
事件是危险和模糊的,因为您正在侦听加载事件并同时加载ajax内容。 请试试这个:var toInsert = $('video from youtube'); $(toInsert).on("load", function() { $(".composition"+concat(number)).after(toInsert); });
您可以以不同的方式使用延迟:
$(toInsert).load('url-to-video', function(response, status, xhr ) { console.log(response, status, xhr ); });
这是两种不同的方法。 不要混合两者!
编辑
查看OP的编辑,我看到可能被监听的iframe,而不是DOM元素。
toInsert.find('iframe').on("load", function() { $(".composition".concat(number)).after(toInsert); });
这里你是解释,因为你不必使用
load()
方法来监听load事件:它产生一个AJAX查询。
load()
event is dangerous and ambiguous, because you are listening load event and load an ajax content simultaneously. Please, try this:var toInsert = $('video from youtube'); $(toInsert).on("load", function() { $(".composition"+concat(number)).after(toInsert); });
You can use a deferred in a different way:
$(toInsert).load('url-to-video', function(response, status, xhr ) { console.log(response, status, xhr ); });
These are two different ways to do it. Don't mix both!
EDIT
Viewing the edit of OP, I see an iframe that may be listened, and not the DOM element.
toInsert.find('iframe').on("load", function() { $(".composition".concat(number)).after(toInsert); });
Here you are the explanation because you don't must to use
load()
method to listening load event:It makes an AJAX query.
相关问答
更多-
使用内联样式, use an inline style,
-
您的网页加载速度缓慢的原因有很多。 在找到解决方法之前,您应首先调查导致缓慢的原因。 基于您的代码,我推测movimentacoes的数量可能太大而无法在单个页面上显示。 如果这是真的,您可以通过只读取一小部分可用数据(足以在单个屏幕上显示)来解决它,并使用分页来浏览数据。 There are many reasons why your page is slow to load. You should first investigate what causes the slowness, before fi ...
-
使用jquery的ajax 。 或者预加载所有内容并使用jquery UI的选项卡 Use jquery's ajax for that. Or alternatively preload all the contents and use jquery UI's tabs
-
试试这个......加载“about:blank” Try this... Load "about:blank"
-
我设法解决了这个问题。 显然主html文件需要位于文件夹结构的根目录下。 很高兴在官方的msdn页面上获得这些信息。 希望至少这可以帮助任何在加载本地页面时可能遇到同样问题的人。 谢谢! I managed to fix the problem. Apparently the main html file needs to be at the root of the folders' structure. Would be nice to have that information on the offic ...
-
为ajaxOptions添加更多选项将允许您根据AJAX调用的路由隐藏和显示加载器。 $(function() { $("#tabs").tabs({ ajaxOptions: { error: function(xhr, status, index, anchor) { $(anchor.hash).html(); }, beforeSend: function() { ...
-
如何在网页上加载此内容后才能显示内容?(How I can show content only after loading this content on a web page? [closed])[2023-08-23]
load()事件是危险和模糊的,因为您正在侦听加载事件并同时加载ajax内容。 请试试这个: var toInsert = $('video from youtube'); $(toInsert).on("load", function() { $(".composition"+concat(number)).after(toInsert); }); 您可以以不同的方式使用延迟: $(toInsert).load('url-to-video', function(respo ... -
尝试 document.body.onload 要么 $(document).ready(function() { // Animate loader off screen $(".spinner").fadeOut(300); $("#showpage").fadeIn(2000); }); 谢谢 try document.body.onload or $(document).ready(function() { // Anim ...
-
这个? function loadContent(page){ $("#contentPlaceHolder").html(''); $("#contentPlaceHolder").load("/ajax/content?page=" + page); } 将gif文件放在div中,当内容加载时,图像将替换为返回的数据。 This? function loadContent(page){ $("#contentPlaceHolde ...
-
Web内容即使已加载页面也不会加载(Web content not loading until it is brought into view even though the page loaded already)[2024-04-09]
我需要补充: html{ overflow-y: scroll!important; -webkit-overflow-scrolling: touch; } I needed to add: html{ overflow-y: scroll!important; -webkit-overflow-scrolling: touch; }