Hi,
I'm trying to implement a client side cache for an ajax based
application but I'm not sure how to deal with the asynchronous nature
of ajax calls in jquery. What I'm basically trying is to create a
function getList() that fetches a snippet of text from the server and
stores it in a variable so that future invocations of getList() no
longer have to contact the server but can immediately return the
content of the cache-variable.

The problem is that two subsequent invocations of getList() result in
both calls contacting the server because the ajax call of the first
invocation hasn't finished yet when the second call to getList()
happens. At first i thought about using the "async" option but
according to the docs this blocks the entire browser. What I'm really
looking for is a way to only make the particular thread synchronous so
that I can store the result before returning from the first getList()
call.

What is the proper way to handle such a situation i jquery?

Regards,
  Dennis

Reply via email to