How to make an asynchronous call in html5 apps .Suppose if i make a async call to get data from server and waiting for response.Meanwhile if i refresh the browser,i will not be able to catch the data b'coz page is reloaded with all variable redefined.so how to get those data even though user refresh the browser or navigate to other page.
I do not believe that this is possible. Once the user refreshes the browser, then any existing calls will act as though they have been cut off.
You COULD try to write logic such that on every browser refresh you check the server for lost calls, but this will get quite complicated.
Most users tend to know that when they browse away from a page, any existing requests will be lost, though.
Whatever variables are getting redefined, you can store in a temporary session. You can either store the data locally with local storage, store it in javascript with cookies, or store the data server-side and reference it with a cookie session.
At that point, you can just have your code realize it needs to download the data and do that as soon as the page gets refreshed.
Alternatively, you can make it so a confirmation prompt comes up on refresh mentioning their data may be lost.
There is no direct way to implement this. You can try Ajax History, when you refresh the page, a new ajax call will be made.