views:

710

answers:

4

I'm using jquery ajax, how to clear the cache of the ajax result?

A: 

You can't actually clear the cache as it's controlled by the browser, but you can ask for the next request not to be cached by adding cache: false to your options.

$.get('/callback/', {cache: false});
Greg
+1  A: 

Are you looking for $.ajax cache option? http://docs.jquery.com/Ajax/jQuery.ajax#options

Trickster
A: 

If you want to bypass the cache you can add some random argument to the url:

var url = 'http://example.com/ajax?' + (new Date()).getTime();
Kimmo Puputti
you just invented new wheel. Congrats :-)
Trickster
A: 

hii, Im having a problm with my code..nd also i dnt knw whthr its d cache problm..Im having 3 radio buttons:educational,non educational nd other services.when i click on educational,i must get the values correspondng 2 educatnal nd wise-versa.. My problm s whn i click in educatn im gettng d value..bt if i click on the educational nd i changed 2 non eductn,im gettng both educatn+non eductn details..nd im nt able 2 enter the appopriate value in that text box.. can u help me in solvng this peoblm....

my code is:

<input name="doctype1" id="doctype1" class="doctype1" type="radio" value="0" tabindex="16" onclick="clearDocType(this.value,1);" checked="checked" />&nbsp;Educational&nbsp;
<input name="doctype1" class="doctype1" id="doctype1" type="radio" value="1" onclick="clearDocType(this.value,1);" />&nbsp;Non Educational&nbsp;<input name="doctype1" id="doctype1" class="doctype1" type="radio" value="2" onclick="clearDocType(this.value,1);" />&nbsp;Other Services


<input name="docdetails1" type="text"class="txtbox extra disabled" id="docdetails1" 
onKeyPress="return disableEnterKey(event)" onblur="txtLostFocus(this,'doc');" onclick="docactivate(1);txtFocus(this,'doc');"value="SSLC/ Diploma/ CBSE/ etc..." />
<input type="hidden"id="docdetails1hiddenid" name="docdetails1hiddenid" />

<script type="text/javascript">
function docactivate(docid){
    //alert($(".doctype"+docid+":checked").val());
    $("#docdetails"+docid).unbind().autocomplete();
    $("#docdetails"+docid).autocomplete('../ParentFiles/autocomplete_new.php?a=6&doc='+$(".doctype"+docid+":checked").val(), {
        width: 300,
        autoFill: true,
        //mustMatch: true,
        matchContains: true
    }).flushCache()
    ;

    $("#docdetails"+docid).result(function(event, data, formatted) {
        var dochidden = $("input#docdetails"+docid+"hiddenid"); 
        if(data!= null){
            dochidden.val(data[1]); 
            $("#docdetails"+docid).removeClass('disabled');
        }
    });

}   
</script>
twinkle
omg ... ! what was that.. please fill in the missing letters from you question .. then copy it and create a new question and paste it in.. And also format your code, by selecting it and using the little `101` button ..
Gaby