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');