2010-09-08 17:54:33 +00:00
|
|
|
(function( jQuery ) {
|
2010-12-09 18:34:28 +00:00
|
|
|
|
|
|
|
var rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
2010-09-22 13:16:28 +00:00
|
|
|
rselectTextarea = /^(?:select|textarea)/i,
|
|
|
|
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
|
|
|
|
rbracket = /\[\]$/,
|
2009-07-19 19:44:15 +00:00
|
|
|
rquery = /\?/,
|
2010-02-11 06:23:13 +00:00
|
|
|
r20 = /%20/g,
|
2009-07-19 19:44:15 +00:00
|
|
|
|
2010-02-11 06:23:13 +00:00
|
|
|
// Keep a copy of the old load method
|
|
|
|
_load = jQuery.fn.load;
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2010-02-11 06:23:13 +00:00
|
|
|
jQuery.fn.extend({
|
2007-09-04 02:55:38 +00:00
|
|
|
load: function( url, params, callback ) {
|
2010-02-27 14:02:13 +00:00
|
|
|
if ( typeof url !== "string" && _load ) {
|
|
|
|
return _load.apply( this, arguments );
|
2009-11-11 19:55:32 +00:00
|
|
|
|
|
|
|
// Don't do a request if no elements are being requested
|
|
|
|
} else if ( !this.length ) {
|
|
|
|
return this;
|
2009-07-19 19:37:11 +00:00
|
|
|
}
|
2006-11-04 21:09:05 +00:00
|
|
|
|
2007-08-25 03:33:08 +00:00
|
|
|
var off = url.indexOf(" ");
|
2007-08-25 03:55:12 +00:00
|
|
|
if ( off >= 0 ) {
|
|
|
|
var selector = url.slice(off, url.length);
|
|
|
|
url = url.slice(0, off);
|
|
|
|
}
|
2007-08-25 03:33:08 +00:00
|
|
|
|
2006-09-30 14:32:49 +00:00
|
|
|
// Default to a GET request
|
|
|
|
var type = "GET";
|
2006-11-04 21:09:05 +00:00
|
|
|
|
2006-09-30 14:32:49 +00:00
|
|
|
// If the second parameter was provided
|
2009-07-19 19:37:11 +00:00
|
|
|
if ( params ) {
|
2006-09-30 14:32:49 +00:00
|
|
|
// If it's a function
|
2007-01-16 11:38:33 +00:00
|
|
|
if ( jQuery.isFunction( params ) ) {
|
2006-09-30 14:32:49 +00:00
|
|
|
// We assume that it's the callback
|
|
|
|
callback = params;
|
|
|
|
params = null;
|
2006-11-04 21:09:05 +00:00
|
|
|
|
2006-09-30 14:32:49 +00:00
|
|
|
// Otherwise, build a param string
|
2009-07-19 19:37:11 +00:00
|
|
|
} else if ( typeof params === "object" ) {
|
2009-12-22 13:09:56 +00:00
|
|
|
params = jQuery.param( params, jQuery.ajaxSettings.traditional );
|
2006-09-30 14:32:49 +00:00
|
|
|
type = "POST";
|
|
|
|
}
|
2009-07-19 19:37:11 +00:00
|
|
|
}
|
2010-12-09 18:34:28 +00:00
|
|
|
|
2010-01-25 02:58:32 +00:00
|
|
|
var self = this;
|
2010-12-09 18:34:28 +00:00
|
|
|
|
2006-09-30 14:32:49 +00:00
|
|
|
// Request the remote document
|
2006-11-03 11:30:57 +00:00
|
|
|
jQuery.ajax({
|
|
|
|
url: url,
|
|
|
|
type: type,
|
2007-12-14 17:06:41 +00:00
|
|
|
dataType: "html",
|
2006-11-03 11:30:57 +00:00
|
|
|
data: params,
|
2009-12-22 00:58:13 +00:00
|
|
|
complete: function( res, status ) {
|
2007-07-20 21:59:52 +00:00
|
|
|
// If successful, inject the HTML into all the matched elements
|
2009-07-19 19:37:11 +00:00
|
|
|
if ( status === "success" || status === "notmodified" ) {
|
2007-08-25 03:33:08 +00:00
|
|
|
// See if a selector was specified
|
2010-01-25 02:58:32 +00:00
|
|
|
self.html( selector ?
|
2007-08-25 03:33:08 +00:00
|
|
|
// Create a dummy div to hold the results
|
2010-09-22 13:16:28 +00:00
|
|
|
jQuery("<div>")
|
2007-08-25 03:33:08 +00:00
|
|
|
// inject the contents of the document in, removing the scripts
|
|
|
|
// to avoid any 'Permission Denied' errors in IE
|
2009-07-19 19:44:15 +00:00
|
|
|
.append(res.responseText.replace(rscript, ""))
|
2007-08-25 03:33:08 +00:00
|
|
|
|
|
|
|
// Locate the specified elements
|
|
|
|
.find(selector) :
|
|
|
|
|
|
|
|
// If not, just inject the full result
|
|
|
|
res.responseText );
|
2009-07-19 19:37:11 +00:00
|
|
|
}
|
2007-07-20 21:59:52 +00:00
|
|
|
|
2009-07-19 19:37:11 +00:00
|
|
|
if ( callback ) {
|
2010-01-25 02:58:32 +00:00
|
|
|
self.each( callback, [res.responseText, status, res] );
|
2009-07-19 19:37:11 +00:00
|
|
|
}
|
2006-11-03 11:30:57 +00:00
|
|
|
}
|
|
|
|
});
|
2009-07-19 19:37:11 +00:00
|
|
|
|
2006-09-30 14:32:49 +00:00
|
|
|
return this;
|
|
|
|
},
|
2006-05-16 16:18:52 +00:00
|
|
|
|
2006-09-30 14:32:49 +00:00
|
|
|
serialize: function() {
|
2007-09-05 17:06:05 +00:00
|
|
|
return jQuery.param(this.serializeArray());
|
|
|
|
},
|
2010-03-02 15:44:48 +00:00
|
|
|
|
2007-09-09 18:29:15 +00:00
|
|
|
serializeArray: function() {
|
2010-12-09 18:34:28 +00:00
|
|
|
return this.map(function(){
|
2008-08-13 01:44:36 +00:00
|
|
|
return this.elements ? jQuery.makeArray(this.elements) : this;
|
2007-09-05 17:06:05 +00:00
|
|
|
})
|
2010-12-09 18:34:28 +00:00
|
|
|
.filter(function(){
|
2008-05-13 01:45:58 +00:00
|
|
|
return this.name && !this.disabled &&
|
2009-07-19 19:44:15 +00:00
|
|
|
(this.checked || rselectTextarea.test(this.nodeName) ||
|
|
|
|
rinput.test(this.type));
|
2007-09-05 17:06:05 +00:00
|
|
|
})
|
2010-12-09 18:34:28 +00:00
|
|
|
.map(function(i, elem){
|
2007-09-09 18:29:15 +00:00
|
|
|
var val = jQuery(this).val();
|
2009-07-19 19:37:11 +00:00
|
|
|
|
|
|
|
return val == null ?
|
|
|
|
null :
|
2008-10-29 02:01:22 +00:00
|
|
|
jQuery.isArray(val) ?
|
2010-12-09 18:34:28 +00:00
|
|
|
jQuery.map( val, function(val, i){
|
|
|
|
return {name: elem.name, value: val};
|
2007-09-05 17:06:05 +00:00
|
|
|
}) :
|
2010-12-09 18:34:28 +00:00
|
|
|
{name: elem.name, value: val};
|
2007-09-09 18:29:15 +00:00
|
|
|
}).get();
|
|
|
|
}
|
2006-09-30 14:32:49 +00:00
|
|
|
});
|
2006-09-08 10:18:46 +00:00
|
|
|
|
2006-06-19 01:29:54 +00:00
|
|
|
// Attach a bunch of functions for handling common AJAX events
|
2010-12-09 18:34:28 +00:00
|
|
|
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function(i,o){
|
|
|
|
jQuery.fn[o] = function(f){
|
2007-01-06 05:31:47 +00:00
|
|
|
return this.bind(o, f);
|
2006-08-17 04:18:32 +00:00
|
|
|
};
|
2007-01-06 05:31:47 +00:00
|
|
|
});
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
|
2010-12-26 18:51:29 +00:00
|
|
|
jQuery.each( [ "GET", "POST" ], function( i, method ) {
|
|
|
|
jQuery[ method.toLowerCase() ] = function( url, data, callback, type ) {
|
2009-09-15 15:28:28 +00:00
|
|
|
// shift arguments if data argument was omited
|
2007-01-14 06:22:20 +00:00
|
|
|
if ( jQuery.isFunction( data ) ) {
|
2009-09-15 16:45:37 +00:00
|
|
|
type = type || callback;
|
2006-07-10 03:20:56 +00:00
|
|
|
callback = data;
|
|
|
|
data = null;
|
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2006-12-15 09:13:24 +00:00
|
|
|
return jQuery.ajax({
|
2010-12-26 18:51:29 +00:00
|
|
|
type: method,
|
2006-11-03 11:30:57 +00:00
|
|
|
url: url,
|
2006-11-11 11:34:51 +00:00
|
|
|
data: data,
|
|
|
|
success: callback,
|
2007-09-04 02:55:38 +00:00
|
|
|
dataType: type
|
2006-11-03 11:30:57 +00:00
|
|
|
});
|
2010-12-26 18:51:29 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery.extend({
|
2006-11-04 21:09:05 +00:00
|
|
|
|
2006-09-30 14:32:49 +00:00
|
|
|
getScript: function( url, callback ) {
|
2006-12-15 09:13:24 +00:00
|
|
|
return jQuery.get(url, null, callback, "script");
|
2006-09-08 10:18:46 +00:00
|
|
|
},
|
2006-11-04 21:09:05 +00:00
|
|
|
|
2006-09-08 10:18:46 +00:00
|
|
|
getJSON: function( url, data, callback ) {
|
2006-12-15 09:13:24 +00:00
|
|
|
return jQuery.get(url, data, callback, "json");
|
2006-07-10 03:20:56 +00:00
|
|
|
},
|
2006-11-04 21:09:05 +00:00
|
|
|
|
2007-01-06 06:18:02 +00:00
|
|
|
ajaxSetup: function( settings ) {
|
2007-08-21 04:46:07 +00:00
|
|
|
jQuery.extend( jQuery.ajaxSettings, settings );
|
2006-08-17 04:18:32 +00:00
|
|
|
},
|
|
|
|
|
2006-12-22 13:56:36 +00:00
|
|
|
ajaxSettings: {
|
2008-05-14 19:50:24 +00:00
|
|
|
url: location.href,
|
2006-12-22 13:56:36 +00:00
|
|
|
global: true,
|
|
|
|
type: "GET",
|
|
|
|
contentType: "application/x-www-form-urlencoded",
|
|
|
|
processData: true,
|
2007-01-14 22:51:55 +00:00
|
|
|
async: true,
|
2009-01-04 21:15:02 +00:00
|
|
|
/*
|
|
|
|
timeout: 0,
|
2008-01-07 01:03:31 +00:00
|
|
|
data: null,
|
2010-12-09 18:34:28 +00:00
|
|
|
dataType: null,
|
|
|
|
dataTypes: null,
|
2008-01-07 01:03:31 +00:00
|
|
|
username: null,
|
2008-01-14 18:19:28 +00:00
|
|
|
password: null,
|
2010-12-09 18:34:28 +00:00
|
|
|
cache: null,
|
2009-12-22 13:09:56 +00:00
|
|
|
traditional: false,
|
2009-01-04 21:15:02 +00:00
|
|
|
*/
|
2010-09-28 17:12:33 +00:00
|
|
|
xhr: function() {
|
|
|
|
return new window.XMLHttpRequest();
|
|
|
|
},
|
2010-12-09 18:34:28 +00:00
|
|
|
xhrResponseFields: {
|
|
|
|
xml: "XML",
|
|
|
|
text: "Text",
|
|
|
|
json: "JSON"
|
|
|
|
},
|
|
|
|
|
2008-01-14 18:19:28 +00:00
|
|
|
accepts: {
|
|
|
|
xml: "application/xml, text/xml",
|
|
|
|
html: "text/html",
|
|
|
|
text: "text/plain",
|
2010-12-09 18:34:28 +00:00
|
|
|
json: "application/json, text/javascript",
|
|
|
|
"*": "*/*"
|
|
|
|
},
|
|
|
|
|
|
|
|
autoDataType: {
|
|
|
|
xml: /xml/,
|
|
|
|
html: /html/,
|
|
|
|
json: /json/
|
|
|
|
},
|
|
|
|
|
|
|
|
// Prefilters
|
|
|
|
// 1) They are useful to introduce custom dataTypes (see transport/jsonp for an example)
|
|
|
|
// 2) These are called:
|
|
|
|
// * BEFORE asking for a transport
|
|
|
|
// * AFTER param serialization (s.data is a string if s.processData is true)
|
|
|
|
// 3) They MUST be order agnostic
|
|
|
|
prefilters: [],
|
|
|
|
|
|
|
|
// Transports bindings
|
|
|
|
// 1) key is the dataType
|
|
|
|
// 2) the catchall symbol "*" can be used
|
|
|
|
// 3) selection will start with transport dataType and THEN go to "*" if needed
|
|
|
|
transports: {
|
|
|
|
},
|
|
|
|
|
|
|
|
// Checkers
|
|
|
|
// 1) key is dataType
|
|
|
|
// 2) they are called to control successful response
|
|
|
|
// 3) error throws is used as error data
|
|
|
|
dataCheckers: {
|
|
|
|
|
|
|
|
// Check if data is a string
|
|
|
|
"text": function(data) {
|
|
|
|
if ( typeof data != "string" ) {
|
|
|
|
jQuery.error("typeerror");
|
2009-07-19 19:03:18 +00:00
|
|
|
}
|
2010-12-09 18:34:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Check if xml has been properly parsed
|
|
|
|
"xml": function(data) {
|
|
|
|
var documentElement = data ? data.documentElement : data;
|
|
|
|
if ( ! documentElement || ! documentElement.nodeName ) {
|
|
|
|
jQuery.error("typeerror");
|
2010-06-15 03:05:01 +00:00
|
|
|
}
|
2010-12-09 18:34:28 +00:00
|
|
|
if ( documentElement.nodeName == "parsererror" ) {
|
|
|
|
jQuery.error("parsererror");
|
2009-06-15 13:36:12 +00:00
|
|
|
}
|
2009-11-25 18:24:24 +00:00
|
|
|
}
|
2010-12-09 18:34:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// List of data converters
|
|
|
|
// 1) key format is "source_type => destination_type" (spaces required)
|
|
|
|
// 2) the catchall symbol "*" can be used for source_type
|
|
|
|
dataConverters: {
|
|
|
|
|
|
|
|
// Convert anything to text
|
|
|
|
"* => text": function(data) {
|
|
|
|
return "" + data;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Text to html (no transformation)
|
|
|
|
"text => html": function(data) {
|
|
|
|
return data;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Evaluate text as a json expression
|
|
|
|
"text => json": jQuery.parseJSON,
|
|
|
|
|
|
|
|
// Parse text as xml
|
|
|
|
"text => xml": function(data) {
|
|
|
|
var xml, parser;
|
|
|
|
if ( window.DOMParser ) { // Standard
|
|
|
|
parser = new DOMParser();
|
|
|
|
xml = parser.parseFromString(data,"text/xml");
|
|
|
|
} else { // IE
|
|
|
|
xml = new ActiveXObject("Microsoft.XMLDOM");
|
|
|
|
xml.async="false";
|
|
|
|
xml.loadXML(data);
|
2009-07-19 19:37:11 +00:00
|
|
|
}
|
2010-12-09 18:34:28 +00:00
|
|
|
return xml;
|
2006-06-19 01:29:54 +00:00
|
|
|
}
|
2006-12-21 13:35:32 +00:00
|
|
|
}
|
2010-12-09 18:34:28 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
// Main method
|
|
|
|
ajax: function( url , s ) {
|
|
|
|
|
|
|
|
if ( arguments.length === 1 ) {
|
|
|
|
s = url;
|
|
|
|
url = s ? s.url : undefined;
|
2009-07-19 19:37:11 +00:00
|
|
|
}
|
2010-12-09 18:34:28 +00:00
|
|
|
|
|
|
|
return jQuery.xhr().open( s ? s.type : undefined , url ).send( undefined , s );
|
|
|
|
|
2010-03-02 02:24:49 +00:00
|
|
|
},
|
2007-09-03 23:45:14 +00:00
|
|
|
|
2010-03-02 02:24:49 +00:00
|
|
|
// Serialize an array of form elements or a set of
|
|
|
|
// key/values into a query string
|
|
|
|
param: function( a, traditional ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var s = [],
|
|
|
|
add = function( key, value ) {
|
|
|
|
// If value is a function, invoke it and return its value
|
|
|
|
value = jQuery.isFunction(value) ? value() : value;
|
|
|
|
s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
|
|
|
|
};
|
2010-03-02 02:24:49 +00:00
|
|
|
|
|
|
|
// Set traditional to true for jQuery <= 1.3.2 behavior.
|
|
|
|
if ( traditional === undefined ) {
|
|
|
|
traditional = jQuery.ajaxSettings.traditional;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If an array was passed in, assume that it is an array of form elements.
|
|
|
|
if ( jQuery.isArray(a) || a.jquery ) {
|
|
|
|
// Serialize the form elements
|
|
|
|
jQuery.each( a, function() {
|
|
|
|
add( this.name, this.value );
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// If traditional, encode the "old" way (the way 1.3.2 or older
|
|
|
|
// did it), otherwise encode params recursively.
|
|
|
|
for ( var prefix in a ) {
|
|
|
|
buildParams( prefix, a[prefix], traditional, add );
|
2009-07-19 19:37:11 +00:00
|
|
|
}
|
2007-09-03 23:45:14 +00:00
|
|
|
}
|
|
|
|
|
2010-03-02 02:24:49 +00:00
|
|
|
// Return the resulting serialization
|
|
|
|
return s.join("&").replace(r20, "+");
|
|
|
|
}
|
|
|
|
});
|
2007-09-03 23:45:14 +00:00
|
|
|
|
2010-03-02 02:24:49 +00:00
|
|
|
function buildParams( prefix, obj, traditional, add ) {
|
2010-09-24 20:57:25 +00:00
|
|
|
if ( jQuery.isArray(obj) && obj.length ) {
|
2010-03-02 02:24:49 +00:00
|
|
|
// Serialize array item.
|
|
|
|
jQuery.each( obj, function( i, v ) {
|
2010-09-22 13:16:28 +00:00
|
|
|
if ( traditional || rbracket.test( prefix ) ) {
|
2010-03-02 02:24:49 +00:00
|
|
|
// Treat each array item as a scalar.
|
|
|
|
add( prefix, v );
|
2007-09-03 23:45:14 +00:00
|
|
|
|
2010-03-02 02:24:49 +00:00
|
|
|
} else {
|
|
|
|
// If array item is non-scalar (array or object), encode its
|
|
|
|
// numeric index to resolve deserialization ambiguity issues.
|
|
|
|
// Note that rack (as of 1.0.0) can't currently deserialize
|
|
|
|
// nested arrays properly, and attempting to do so may cause
|
|
|
|
// a server error. Possible fixes are to modify rack's
|
|
|
|
// deserialization algorithm or to provide an option or flag
|
|
|
|
// to force array serialization to be shallow.
|
|
|
|
buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
|
2009-07-19 19:37:11 +00:00
|
|
|
}
|
2010-03-02 02:24:49 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
} else if ( !traditional && obj != null && typeof obj === "object" ) {
|
2010-12-23 00:54:22 +00:00
|
|
|
// If we see an array here, it is empty and should be treated as an empty
|
|
|
|
// object
|
|
|
|
if ( jQuery.isArray( obj ) || jQuery.isEmptyObject( obj ) ) {
|
2010-09-24 20:57:25 +00:00
|
|
|
add( prefix, "" );
|
|
|
|
|
2010-03-02 02:24:49 +00:00
|
|
|
// Serialize object item.
|
2010-09-24 20:57:25 +00:00
|
|
|
} else {
|
|
|
|
jQuery.each( obj, function( k, v ) {
|
|
|
|
buildParams( prefix + "[" + k + "]", v, traditional, add );
|
|
|
|
});
|
|
|
|
}
|
2010-03-02 02:24:49 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// Serialize scalar item.
|
|
|
|
add( prefix, obj );
|
|
|
|
}
|
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2010-10-11 22:29:52 +00:00
|
|
|
// This is still on the jQuery object... for now
|
|
|
|
// Want to move this to jQuery.ajax some day
|
|
|
|
jQuery.extend({
|
2010-03-02 02:24:49 +00:00
|
|
|
|
|
|
|
// Counter for holding the number of active queries
|
|
|
|
active: 0,
|
2006-11-04 21:09:05 +00:00
|
|
|
|
2010-03-02 15:44:48 +00:00
|
|
|
// Last-Modified header cache for next request
|
|
|
|
lastModified: {},
|
2010-12-09 18:34:28 +00:00
|
|
|
etag: {}
|
2010-03-02 02:24:49 +00:00
|
|
|
|
2006-07-10 03:20:56 +00:00
|
|
|
});
|
2010-03-02 15:44:48 +00:00
|
|
|
|
2010-09-28 17:12:33 +00:00
|
|
|
/*
|
|
|
|
* Create the request object; Microsoft failed to properly
|
|
|
|
* implement the XMLHttpRequest in IE7 (can't request local files),
|
|
|
|
* so we use the ActiveXObject when it is available
|
|
|
|
* Additionally XMLHttpRequest can be disabled in IE7/IE8 so
|
|
|
|
* we need a fallback.
|
|
|
|
*/
|
|
|
|
if ( window.ActiveXObject ) {
|
|
|
|
jQuery.ajaxSettings.xhr = function() {
|
2010-12-09 18:34:28 +00:00
|
|
|
if ( window.location.protocol !== "file:" ) {
|
2010-09-28 17:12:33 +00:00
|
|
|
try {
|
2010-12-09 18:34:28 +00:00
|
|
|
return new window.XMLHttpRequest();
|
|
|
|
} catch( xhrError ) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
return new window.ActiveXObject("Microsoft.XMLHTTP");
|
|
|
|
} catch( activeError ) {}
|
2010-09-28 17:12:33 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
var testXHR = jQuery.ajaxSettings.xhr();
|
|
|
|
|
2010-09-13 22:02:33 +00:00
|
|
|
// Does this browser support XHR requests?
|
2010-12-09 18:34:28 +00:00
|
|
|
jQuery.support.ajax = !!testXHR;
|
|
|
|
|
|
|
|
// Does this browser support crossDomain XHR requests
|
|
|
|
jQuery.support.cors = testXHR && "withCredentials" in testXHR;
|
2010-09-13 22:02:33 +00:00
|
|
|
|
2010-12-10 02:16:50 +00:00
|
|
|
})( jQuery );
|