Renamed $.ajax's "before"-option to "beforeSend" to prevent conflict with form plugin - may be a good convention to use beforeXXX and afterXXX everytime for callbacks...

This commit is contained in:
Jörn Zaefferer 2006-12-05 22:58:27 +00:00
parent 47a6a32b27
commit f1c91fd023
3 changed files with 8 additions and 8 deletions

View file

@ -19,7 +19,7 @@ if($name == 'foo') {
die(); die();
} }
$request = apache_request_headers(); $request = apache_request_headers();
$request = $request['customHeader']; $request = $request['X-Custom-Header'];
if(strlen($request) > 0) { if(strlen($request) > 0) {
echo $request; echo $request;
die(); die();

View file

@ -484,7 +484,7 @@ jQuery.extend({
* (Boolean) async - By default, all requests are send asynchronous (set to true). * (Boolean) async - By default, all requests are send asynchronous (set to true).
* If you need synchronous requests, set this option to false. * If you need synchronous requests, set this option to false.
* *
* (Function) before - A pre-callback to set custom headers etc., the * (Function) beforeSend - A pre-callback to set custom headers etc., the
* XMLHttpRequest is passed as the only argument. * XMLHttpRequest is passed as the only argument.
* *
* @example $.ajax({ * @example $.ajax({
@ -525,7 +525,7 @@ jQuery.extend({
contentType: "application/x-www-form-urlencoded", contentType: "application/x-www-form-urlencoded",
processData: true, processData: true,
async: true, async: true,
before: null beforeSend: null
}, s); }, s);
// if data available // if data available
@ -568,8 +568,8 @@ jQuery.extend({
xml.setRequestHeader("Connection", "close"); xml.setRequestHeader("Connection", "close");
// Allow custom headers/mimetypes // Allow custom headers/mimetypes
if( s.before ) if( s.beforeSend )
s.before(xml); s.beforeSend(xml);
// Wait for a response to come back // Wait for a response to come back
var onreadystatechange = function(isTimeout){ var onreadystatechange = function(isTimeout){

View file

@ -282,12 +282,12 @@ test("$.ajax - xml: non-namespace elements inside namespaced elements", function
test("$.ajax - preprocess", function() { test("$.ajax - preprocess", function() {
expect(1); expect(1);
stop(); stop();
var customHeader = "value-for-custom-header"; var customHeader = "value";
$.ajax({ $.ajax({
url: "data/name.php", url: "data/name.php",
data: {'req': true}, data: {'req': true},
before: function(xml) { beforeSend: function(xml) {
xml.setRequestHeader('customHeader', customHeader) xml.setRequestHeader('X-Custom-Header', customHeader);
}, },
success: function(data) { success: function(data) {
ok( data == customHeader, "check return value, should be the custom header sent" ); ok( data == customHeader, "check return value, should be the custom header sent" );