I just downloaded the newest version from http://jquery.com and tried it as
is, no zipping or packing, same result, here is the $.post function:
post: function( url, data, callback, type ) {
if ( jQuery.isFunction( data ) ) {
callback = data;
data = {};
}
return jQuery.ajax({
type: "POST",
url: url,
data: data,
success: callback,
dataType: type
});
}
So it is depends on the ajax function:
ajax: function( s ) {
// Extend the settings, but re-extend 's' so that it can be
// checked again later (in the test suite, specifically)
s = jQuery.extend(true, s, jQuery.extend(true, {},
jQuery.ajaxSettings, s));
var jsonp, jsre = /=\?(&|$)/g, status, data,
type = s.type.toUpperCase();
// convert data if not already a string
if ( s.data && s.processData && typeof s.data != "string" )
s.data = jQuery.param(s.data);
// Handle JSONP Parameter Callbacks
if ( s.dataType == "jsonp" ) {
if ( type == "GET" ) {
if ( !s.url.match(jsre) )
s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp ||
"callback") + "=?";
} else if ( !s.data || !s.data.match(jsre) )
s.data = (s.data ? s.data + "&" : "") + (s.jsonp ||
"callback") + "=?";
s.dataType = "json";
}
// Build temporary JSONP function
if ( s.dataType == "json" && (s.data && s.data.match(jsre) ||
s.url.match(jsre)) ) {
jsonp = "jsonp" + jsc++;
// Replace the =? sequence both in the query string and the data
if ( s.data )
s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
s.url = s.url.replace(jsre, "=" + jsonp + "$1");
// We need to make sure
// that a JSONP style response is executed properly
s.dataType = "script";
// Handle JSONP-style loading
window[ jsonp ] = function(tmp){
data = tmp;
success();
complete();
// Garbage collect
window[ jsonp ] = undefined;
try{ delete window[ jsonp ]; } catch(e){}
if ( head )
head.removeChild( script );
};
}
if ( s.dataType == "script" && s.cache == null )
s.cache = false;
if ( s.cache === false && type == "GET" ) {
var ts = now();
// try replacing _= if it is there
var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
// if nothing was replaced, add timestamp to the end
s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?")
+ "_=" + ts : "");
}
// If data is available, append data to url for get requests
if ( s.data && type == "GET" ) {
s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
// IE likes to send both get and post data, prevent this
s.data = null;
}
// Watch for a new set of requests
if ( s.global && ! jQuery.active++ )
jQuery.event.trigger( "ajaxStart" );
// Matches an absolute URL, and saves the domain
var remote = /^(?:\w+:)?\/\/([^\/?#]+)/;
// If we're requesting a remote document
// and trying to load JSON or Script with a GET
if ( s.dataType == "script" && type == "GET"
&& remote.test(s.url) && remote.exec(s.url)[1] !=
location.host ){
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = s.url;
if (s.scriptCharset)
script.charset = s.scriptCharset;
// Handle Script loading
if ( !jsonp ) {
var done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
if ( !done && (!this.readyState ||
this.readyState == "loaded" || this.readyState
== "complete") ) {
done = true;
success();
complete();
head.removeChild( script );
}
};
}
head.appendChild(script);
// We handle everything using the script element injection
return undefined;
}
var requestDone = false;
// Create the request object; Microsoft failed to properly
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject
when it is available
var xhr = window.ActiveXObject ? new
ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
// Open the socket
// Passing null username, generates a login popup on Opera (#2865)
if( s.username )
xhr.open(type, s.url, s.async, s.username, s.password);
else
xhr.open(type, s.url, s.async);
// Need an extra try/catch for cross domain requests in Firefox 3
try {
// Set the correct header, if data is being sent
if ( s.data )
xhr.setRequestHeader("Content-Type", s.contentType);
// Set the If-Modified-Since header, if ifModified mode.
if ( s.ifModified )
xhr.setRequestHeader("If-Modified-Since",
jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00
GMT" );
// Set header so the called script knows that it's an
XMLHttpRequest
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
// Set the Accepts header for the server, depending on the
dataType
xhr.setRequestHeader("Accept", s.dataType && s.accepts[
s.dataType ] ?
s.accepts[ s.dataType ] + ", */*" :
s.accepts._default );
} catch(e){}
// Allow custom headers/mimetypes
if ( s.beforeSend && s.beforeSend(xhr, s) === false ) {
// cleanup active request counter
s.global && jQuery.active--;
// close opended socket
xhr.abort();
return false;
}
if ( s.global )
jQuery.event.trigger("ajaxSend", [xhr, s]);
// Wait for a response to come back
var onreadystatechange = function(isTimeout){
// The transfer is complete and the data is available, or the
request timed out
if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout ==
"timeout") ) {
requestDone = true;
// clear poll interval
if (ival) {
clearInterval(ival);
ival = null;
}
status = isTimeout == "timeout" && "timeout" ||
!jQuery.httpSuccess( xhr ) && "error" ||
s.ifModified && jQuery.httpNotModified( xhr, s.url ) &&
"notmodified" ||
"success";
if ( status == "success" ) {
// Watch for, and catch, XML document parse errors
try {
// process the data (runs the xml through httpData
regardless of callback)
data = jQuery.httpData( xhr, s.dataType,
s.dataFilter );
} catch(e) {
status = "parsererror";
}
}
// Make sure that the request was successful or notmodified
if ( status == "success" ) {
// Cache Last-Modified header, if ifModified mode.
var modRes;
try {
modRes = xhr.getResponseHeader("Last-Modified");
} catch(e) {} // swallow exception thrown by FF if
header is not available
if ( s.ifModified && modRes )
jQuery.lastModified[s.url] = modRes;
// JSONP handles its own success callback
if ( !jsonp )
success();
} else
jQuery.handleError(s, xhr, status);
// Fire the complete handlers
complete();
// Stop memory leaks
if ( s.async )
xhr = null;
}
};
if ( s.async ) {
// don't attach the handler to the request, just poll it instead
var ival = setInterval(onreadystatechange, 13);
// Timeout checker
if ( s.timeout > 0 )
setTimeout(function(){
// Check to see if the request is still happening
if ( xhr ) {
// Cancel the request
xhr.abort();
if( !requestDone )
onreadystatechange( "timeout" );
}
}, s.timeout);
}
// Send the data
try {
xhr.send(s.data);
} catch(e) {
jQuery.handleError(s, xhr, null, e);
}
// firefox 1.5 doesn't fire statechange for sync requests
if ( !s.async )
onreadystatechange();
function success(){
// If a local callback was specified, fire it and pass it the
data
if ( s.success )
s.success( data, status );
// Fire the global callback
if ( s.global )
jQuery.event.trigger( "ajaxSuccess", [xhr, s] );
}
function complete(){
// Process result
if ( s.complete )
s.complete(xhr, status);
// The request was completed
if ( s.global )
jQuery.event.trigger( "ajaxComplete", [xhr, s] );
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
}
// return XMLHttpRequest to allow aborting the request etc.
return xhr;
},
The above works flawlessly with Apache + PHP.
/Henrik
------=_Part_38217_10429206.1223201211828
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
<div dir="ltr">I just downloaded the newest version from <a
href="http://jquery.com">http://jquery.com</a> and tried it as is, no zipping
or packing, same result, here is the $.post function:<br><br>
post: function( url, data, callback, type ) {<br>
if ( jQuery.isFunction( data ) )
{<br> callback =
data;<br> data =
{};<br> }<br><br>
return jQuery.ajax({<br>
type:
"POST",<br>
url: url,<br> data:
data,<br>
success:
callback,<br> dataType:
type<br> });<br>
}<br><br>So it is depends on the ajax function:<br><br> ajax:
function( s ) {<br> // Extend the
settings, but re-extend 's' so that it can be<br>
// checked again later (in the test
suite, specifically)<br> s =
jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings,
s));<br><br> var jsonp, jsre =
/=\?(&|$)/g, status, data,<br>
type = s.type.toUpperCase();<br>
<br> // convert data if not already a
string<br> if ( s.data &&
s.processData && typeof s.data != "string"
)<br> s.data =
jQuery.param(s.data);<br><br> // Handle
JSONP Parameter Callbacks<br>
if ( s.dataType == "jsonp" )
{<br> if ( type ==
"GET" ) {<br>
if ( !s.url.match(jsre) )<br>
s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp ||
"callback") + "=?";<br>
} else if ( !s.data ||
!s.data.match(jsre) )<br>
s.data = (s.data ? s.data +
"&" : "") + (s.jsonp || "callback") +
"=?";<br>
s.dataType = "json";<br>
}<br><br>
// Build temporary JSONP function<br>
if ( s.dataType == "json" && (s.data
&& s.data.match(jsre) || s.url.match(jsre)) ) {<br>
jsonp = "jsonp" + jsc++;<br>
<br> // Replace the =?
sequence both in the query string and the data<br>
if ( s.data )<br>
s.data = (s.data +
"").replace(jsre, "=" + jsonp +
"$1");<br>
s.url = s.url.replace(jsre, "=" + jsonp + "$1");<br>
<br> // We need to make
sure<br> // that a
JSONP style response is executed properly<br>
s.dataType =
"script";<br><br>
// Handle JSONP-style loading<br>
window[ jsonp ] = function(tmp){<br>
data = tmp;<br>
success();<br>
complete();<br>
// Garbage
collect<br>
window[ jsonp ] = undefined;<br>
try{ delete window[
jsonp ]; } catch(e){}<br>
if
( head )<br>
head.removeChild( script
);<br>
};<br> }<br><br>
if ( s.dataType == "script" && s.cache ==
null )<br> s.cache =
false;<br>
<br> if ( s.cache === false &&
type == "GET" ) {<br>
var ts = now();<br>
// try replacing _= if it is there<br>
var ret =
s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts +
"$2");<br>
// if nothing was
replaced, add timestamp to the end<br>
s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ?
"&" : "?") + "_=" + ts :
"");<br> }<br>
<br> // If data is available, append data
to url for get requests<br> if ( s.data
&& type == "GET" ) {<br>
s.url += (s.url.match(/\?/) ? "&" :
"?") + s.data;<br>
<br> // IE likes to
send both get and post data, prevent this<br>
s.data = null;<br>
}<br><br> // Watch for
a new set of requests<br> if ( s.global
&& ! jQuery.active++ )<br>
jQuery.event.trigger(
"ajaxStart" );<br><br> //
Matches an absolute URL, and saves the domain<br>
var remote =
/^(?:\w+:)?\/\/([^\/?#]+)/;<br><br> // If
we're requesting a remote document<br>
// and trying to load JSON or Script with
a GET<br> if ( s.dataType ==
"script" && type == "GET"<br>
&&
remote.test(s.url) && remote.exec(s.url)[1] != location.host ){<br>
var head =
document.getElementsByTagName("head")[0];<br>
var script =
document.createElement("script");<br>
script.src = s.url;<br>
if (s.scriptCharset)<br>
script.charset = s.scriptCharset;<br><br>
// Handle Script loading<br>
if ( !jsonp ) {<br>
var done =
false;<br><br>
// Attach handlers for all browsers<br>
script.onload = script.onreadystatechange = function(){<br>
if
( !done && (!this.readyState ||<br>
this.readyState == "loaded" ||
this.readyState == "complete") ) {<br>
done = true;<br>
success();<br>
complete();<br>
head.removeChild(
script );<br>
}<br>
};<br> }<br>
<br>
head.appendChild(script);<br><br>
// We handle everything using the script element
injection<br> return
undefined;<br> }<br><br>
var requestDone = false;<br><br>
// Create the request object; Microsoft failed to
properly<br>
// implement the XMLHttpRequest in IE7,
so we use the ActiveXObject when it is available<br>
var xhr = window.ActiveXObject ? new
ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();<br><br>
// Open the socket<br>
// Passing null username, generates a login popup on Opera
(#2865)<br> if( s.username
)<br> xhr.open(type,
s.url, s.async, s.username, s.password);<br>
else<br>
xhr.open(type, s.url,
s.async);<br><br> // Need an extra
try/catch for cross domain requests in Firefox 3<br>
try {<br>
// Set the correct header, if data is being
sent<br> if ( s.data
)<br>
xhr.setRequestHeader("Content-Type",
s.contentType);<br><br>
// Set the If-Modified-Since header, if ifModified mode.<br>
if ( s.ifModified )<br>
xhr.setRequestHeader("If-Modified-Since",<br>
jQuery.lastModified[s.url] || "Thu, 01 Jan 1970
00:00:00 GMT" );<br><br>
// Set header so the called script knows that it's an
XMLHttpRequest<br>
xhr.setRequestHeader("X-Requested-With",
"XMLHttpRequest");<br>
<br> // Set the Accepts
header for the server, depending on the dataType<br>
xhr.setRequestHeader("Accept",
s.dataType && s.accepts[ s.dataType ] ?<br>
s.accepts[ s.dataType
] + ", */*" :<br>
s.accepts._default );<br> }
catch(e){}<br><br> // Allow custom
headers/mimetypes<br> if ( s.beforeSend
&& s.beforeSend(xhr, s) === false ) {<br>
// cleanup active request counter<br>
s.global &&
jQuery.active--;<br> //
close opended socket<br>
xhr.abort();<br>
return false;<br>
}<br><br> if ( s.global
)<br>
jQuery.event.trigger("ajaxSend", [xhr, s]);<br>
<br> // Wait for a response to come
back<br> var onreadystatechange =
function(isTimeout){<br>
// The transfer is complete and the data is available, or
the request timed out<br>
if ( !requestDone && xhr && (xhr.readyState
== 4 || isTimeout == "timeout") ) {<br>
requestDone = true;<br><br>
// clear poll
interval<br>
if (ival) {<br>
clearInterval(ival);<br>
ival =
null;<br>
}<br><br>
status = isTimeout == "timeout" && "timeout"
||<br>
!jQuery.httpSuccess( xhr ) &&
"error" ||<br>
s.ifModified
&& jQuery.httpNotModified( xhr, s.url ) &&
"notmodified" ||<br>
"success";<br><br>
if ( status ==
"success" ) {<br>
// Watch for, and
catch, XML document parse errors<br>
try
{<br>
// process the data
(runs the xml through httpData regardless of callback)<br>
data = jQuery.httpData( xhr, s.dataType,
s.dataFilter );<br>
} catch(e) {<br>
status = "parsererror";<br>
}<br>
}<br>
<br>
// Make sure that the request was successful or
notmodified<br>
if ( status == "success" ) {<br>
//
Cache Last-Modified header, if ifModified mode.<br>
var
modRes;<br>
try {<br>
modRes =
xhr.getResponseHeader("Last-Modified");<br>
}
catch(e) {} // swallow exception thrown by FF if header is not
available<br><br>
if ( s.ifModified && modRes )<br>
jQuery.lastModified[s.url] =
modRes;<br><br>
// JSONP handles its own success
callback<br>
if ( !jsonp )<br>
success();<br>
} else<br>
jQuery.handleError(s, xhr,
status);<br><br>
// Fire the complete handlers<br>
complete();<br><br>
// Stop memory leaks<br>
if ( s.async )<br>
xhr = null;<br>
}<br>
};<br><br> if ( s.async )
{<br> // don't
attach the handler to the request, just poll it instead<br>
var ival =
setInterval(onreadystatechange, 13);<br>
<br> // Timeout
checker<br> if (
s.timeout > 0 )<br>
setTimeout(function(){<br>
//
Check to see if the request is still happening<br>
if
( xhr ) {<br>
// Cancel the
request<br>
xhr.abort();<br><br>
if( !requestDone
)<br>
onreadystatechange( "timeout" );<br>
}<br>
},
s.timeout);<br>
}<br><br> // Send the
data<br> try {<br>
xhr.send(s.data);<br>
} catch(e) {<br>
jQuery.handleError(s, xhr, null, e);<br>
}<br><br>
// firefox 1.5 doesn't fire
statechange for sync requests<br> if (
!s.async )<br>
onreadystatechange();<br><br> function
success(){<br> // If a
local callback was specified, fire it and pass it the data<br>
if ( s.success
)<br>
s.success( data, status );<br><br>
// Fire the global
callback<br> if (
s.global )<br>
jQuery.event.trigger( "ajaxSuccess", [xhr, s]
);<br>
}<br><br>
function complete(){<br>
// Process result<br>
if ( s.complete )<br>
s.complete(xhr,
status);<br><br> // The
request was completed<br>
if ( s.global )<br>
jQuery.event.trigger( "ajaxComplete", [xhr, s]
);<br><br> // Handle
the global AJAX counter<br>
if ( s.global && ! --jQuery.active
)<br>
jQuery.event.trigger( "ajaxStop" );<br>
}<br><br>
// return XMLHttpRequest to allow aborting the request
etc.<br> return xhr;<br>
},<br><br>The above works flawlessly with Apache + PHP.<br><br>/Henrik<br></div>
------=_Part_38217_10429206.1223201211828--
--
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]