Two quick tips for image refreshing and download dialogue
As we are moving to use more and more "AJAX" on pothi.com, I keep learning new things everyday some of which really entertain me :-). So let me put them down here. How to make sure that an image refreshes from server and not from cache? Suppose you have an img tag and the file in its src attribute is being updated on the server through a ajax call. Now we have to make sure that when the src file changes, the image on the page is also refreshed. On its own, the browser will simply use the version of the file in the cache. To avoid that, you can simply attach a GET query to the end of the image url. So src="test.png" becomes something like - src="test.png?random=<any randomly generated string>". For the random string you can use the surrent time stamp. Short and sweet :-) How to show a download dialogue for files that browser usually opens without asking? Browsers usually have a mapping of MIME types and applications. If they get data of a particular m...