I am populating a dropdown from a jquery ajax call to a web service that is returning json data. If for some reason the webservice fails or is unavailable how do I handle this? I don’t want to have my users looking at an empty dropdown.
How can I cache the last successful call and use that instead?
If the data is the same for all users and doesn’t change too frequently, you could cache it on your server, and only do the AJAX call if cache is unavailable/stale. (If cache is stale, yet AJAX call fails, it may be better to serve slightly stale data than no data.)