var jsc = now();
jQuery.extend({
-
+
get: function( url, data, callback, type ) {
// shift arguments if data argument was ommited
if ( jQuery.isFunction( data ) ) {
// 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
};
}
- head.appendChild(script);
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
// We handle everything using the script element injection
return undefined;
// Send the data
try {
- xhr.send(s.data);
+ xhr.send( type === "POST" ? s.data : null );
} catch(e) {
jQuery.handleError(s, xhr, null, e);
}
xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
data = xml ? xhr.responseXML : xhr.responseText;
- if ( xml && data.documentElement.tagName == "parsererror" )
+ if ( xml && data.documentElement.tagName == "parsererror" ) {
throw "parsererror";
-
+ }
+
// Allow a pre-filtering function to sanitize the response
// s != null is checked to keep backwards compatibility
- if( s && s.dataFilter )
+ if ( s && s.dataFilter ) {
data = s.dataFilter( data, type );
+ }
// The filter can actually parse the response
- if( typeof data === "string" ){
+ if ( typeof data === "string" ) {
// If the type is "script", eval it in global context
- if ( type == "script" )
+ if ( type === "script" ) {
jQuery.globalEval( data );
+ }
// Get the JavaScript object, if JSON is used.
- if ( type == "json" )
- data = window["eval"]("(" + data + ")");
+ if ( type == "json" ) {
+ if ( typeof JSON === "object" && JSON.parse ) {
+ data = JSON.parse( data );
+ } else {
+ data = (new Function("return " + data))();
+ }
+ }
}
-
+
return data;
},