Bug Tracker

Changeset 5605

Show
Ignore:
Timestamp:
05/15/08 14:16:19 (8 months ago)
Author:
aflesler
Message:

jquery ajax: caching repetive conversions/checks for settings.type in $.ajax.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/src/ajax.js

    r5604 r5605  
    166166 
    167167    ajax: function( s ) { 
    168         var jsonp, jsre = /=\?(&|$)/g, status, data; 
    169  
    170168        // Extend the settings, but re-extend 's' so that it can be 
    171169        // checked again later (in the test suite, specifically) 
    172170        s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); 
    173171 
     172        var jsonp, jsre = /=\?(&|$)/g, status, data, 
     173            type = s.type.toUpperCase(); 
     174 
    174175        // convert data if not already a string 
    175176        if ( s.data && s.processData && typeof s.data != "string" ) 
     
    178179        // Handle JSONP Parameter Callbacks 
    179180        if ( s.dataType == "jsonp" ) { 
    180             if ( s.type.toLowerCase() == "get" ) { 
     181            if ( type == "GET" ) { 
    181182                if ( !s.url.match(jsre) ) 
    182183                    s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; 
     
    215216            s.cache = false; 
    216217 
    217         if ( s.cache === false && s.type.toLowerCase() == "get" ) { 
     218        if ( s.cache === false && type == "GET" ) { 
    218219            var ts = now(); 
    219220            // try replacing _= if it is there 
     
    224225 
    225226        // If data is available, append data to url for get requests 
    226         if ( s.data && s.type.toLowerCase() == "get" ) { 
     227        if ( s.data && type == "GET" ) { 
    227228            s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; 
    228229 
     
    240241        // If we're requesting a remote document 
    241242        // and trying to load JSON or Script with a GET 
    242         if ( s.dataType == "script" && s.type.toLowerCase() == "get" 
     243        if ( s.dataType == "script" && type == "GET" 
    243244                && remote.test(s.url) && remote.exec(s.url)[1] != location.host ){ 
    244245            var head = document.getElementsByTagName("head")[0]; 
     
    279280        // Passing null username, generates a login popup on Opera (#2865) 
    280281        if( s.username ) 
    281             xml.open(s.type, s.url, s.async, s.username, s.password); 
     282            xml.open(type, s.url, s.async, s.username, s.password); 
    282283        else 
    283             xml.open(s.type, s.url, s.async); 
     284            xml.open(type, s.url, s.async); 
    284285 
    285286        // Need an extra try/catch for cross domain requests in Firefox 3