Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#9275 closed enhancement (duplicate)

ajax, "no cache" variable name

Reported by: [email protected] Owned by:
Priority: undecided Milestone: 1.next
Component: ajax Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

Description

Sugestion:

Oracle mod_plsql does not accept a variable named as "_". This causes erros when trying to use jquery ajax with oracle.

To fix this i changed the jquery code replacing "_" with "no_cache". But its no cool because I can´t use the minified version and to update I always have to remember this change.

if ( s.cache === false ) {
    ...
    //s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); // o Cardia
    s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "no_cache=" + ts : "" ); // n Cardia
    ...
}

I think its very simple to make this variable name be set up with .ajaxSetup. Can you do that to to future versions? Like:

$.ajaxSetup({
    NO_CACHE_VARIABLE_NAME: "no_cache"
});
...
s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + NO_CACHE_VARIABLE_NAME + "=" + ts : "" );
...

Thanks

Change History (5)

comment:1 Changed 12 years ago by ajpiano

Component: unfiledajax
Status: newopen

I don't think this is an unreasonable request, perhaps we can land it in 1.7! Can you add it to the list of 1.7 proposals in this spreadsheet? Thanks for your time.

comment:2 Changed 12 years ago by miketaylr

+1

comment:3 Changed 12 years ago by jaubourg

Resolution: duplicate
Status: openclosed
$.ajaxPrefilter(function( options ) {
    if ( !options.cache && options.noCacheParameter ) {
        options.url += ( /\?/.test( options.url ) ? "&" : "?" ) +
            options.noCacheParameter + "=" + jQuery.now();
        options.cache = true;
    }
});

$.ajaxSetup({
    noCacheParameter: "no_cache"
});

This kind of environment specific needs is exactly why prefilters have been introduced in the first place.

This has been discussed before and a similar solution was proposed by jitter then.

We have to stop adding options in ajax for very specific use cases (especially now that we have extension points for ajax that makes said options unnecessary in core). We'll have to deal with xhr2 stuff soon enough where new options will be introduced and code size will yet again grow, let's avoid other sources of bloat.

comment:4 Changed 12 years ago by jaubourg

Duplicate of #8305.

comment:5 Changed 12 years ago by ajpiano

jaubourg is right.

Note: See TracTickets for help on using tickets.