admin管理员组文章数量:1319476
I have a WCF service which takes a long time to process the first time it is called, and then caches those results in HttpRuntime.Cache
. In order to initialize this cache I'd like to trigger a fire-and-forget ajax call from javascript.
Right now I have this javascript in the page:
$.ajax({
type: 'GET',
url: getServiceURL() + 'PrimeCacheAjax',
contentType: 'application/json; charset=utf-8'
});
Where the PrimeCacheAjax
function just performs a dummy call to populate the cache.
The only issue with this approach is that the page with this ajax call is a type of landing page which executes some javascript, opens another window and closes itself. When the window closes itself before the server responds, I see a cancelled request in fiddler. I am concerned that this may lead to situations where the ajax call may not reach the server, is this possible?
Is there a way to specify (using $.ajax()
) that no response will be ing, or does it not really matter?
I have a WCF service which takes a long time to process the first time it is called, and then caches those results in HttpRuntime.Cache
. In order to initialize this cache I'd like to trigger a fire-and-forget ajax call from javascript.
Right now I have this javascript in the page:
$.ajax({
type: 'GET',
url: getServiceURL() + 'PrimeCacheAjax',
contentType: 'application/json; charset=utf-8'
});
Where the PrimeCacheAjax
function just performs a dummy call to populate the cache.
The only issue with this approach is that the page with this ajax call is a type of landing page which executes some javascript, opens another window and closes itself. When the window closes itself before the server responds, I see a cancelled request in fiddler. I am concerned that this may lead to situations where the ajax call may not reach the server, is this possible?
Is there a way to specify (using $.ajax()
) that no response will be ing, or does it not really matter?
-
6
Just perform an
$.ajax
call with no callback, which is exactly what your code will do. – Blazemonger Commented Dec 11, 2012 at 19:46
2 Answers
Reset to default 7Only time it will matter is if the request to the server is not plete. You should check to make sure the call is at a readyState value of 2 [aka sent], before exiting.
I would just perform a call with no callback, I don't believe there is a property that allows the F&F method.
for a very short ajax call you could try the following code as an alternative, if you wanted.
$.get('URL');
本文标签: javascriptFire a oneway ajax callStack Overflow
版权声明:本文标题:javascript - Fire a one-way ajax call - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742059300a2418484.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论