Bug Tracker

Changeset 5478

Show
Ignore:
Timestamp:
05/06/08 22:21:43 (7 months ago)
Author:
joern.zaefferer
Message:

jquery ajax: support for dynamic data arguments, see #2806; added test/data/echoQuery.php for easier testing of sent query strings

Location:
trunk/jquery
Files:
1 added
2 modified

Legend:

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

    r5374 r5478  
    490490                    }); 
    491491                else 
    492                     s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) ); 
     492                    s.push( encodeURIComponent(j) + "=" + encodeURIComponent( jQuery.isFunction(a[j]) ? a[j]() : a[j] ) ); 
    493493 
    494494        // Return the resulting serialization 
  • trunk/jquery/test/unit/ajax.js

    r5472 r5478  
    812812}); 
    813813 
     814test("data option: evaluate function values (#2806)", function() { 
     815    stop(); 
     816    $.ajax({ 
     817        url: "data/echoQuery.php", 
     818        data: { 
     819            key: function() { 
     820                return "value"; 
     821            } 
     822        }, 
     823        success: function(result) { 
     824            equals( result, "key=value" ); 
     825            start(); 
     826        } 
     827    }) 
     828}); 
     829 
    814830} 
    815831