John John - 10 months ago 46
Ajax Question

removing cached information from ajax call in the modal dialog

I am displaying a modal(bootstrap) dialog when a user clicks on a row of a table. Here is a small piece of code that I am using :

.done (function (data_, textStatus_, jqXHR_) {


The above code is grabbing a JSON value and displaying in the dialog. I am facing cache related problem I believe in my ajax call. The previous contents of the dialog are not getting removed and I have to basically clear the cache from my browser and click on a particular row again to see what I want to see.I tried using
cache : false
, doing this added a date based timestamp in the URL but still I saw old contents on my dialog. Some SO posts have suggested to destroy the modal but it won't open again I believe. Is there any better approach I can follow to make sure I don't see previous contents in my dialog? I am using chrome as my browser.


I think it's not a cached problem, but DOM manipulation problem. You should replace the content inside #employee_document_contents instead of appendTo it.

Try this code inside your callback function:

var content = $('<pre />').html(doc_contents[1].text_content);
$('#employee_document_contents').html(content); // Here you replace the content