- var t = "GET";
- if ( o && o.constructor == Function ) {
- f = o;
- o = null;
- }
- if (o !== null) {
- o = $.param(o);
- t = "POST";
- }
- var self = this;
- $.xml(t,a,o,function(h){
- h = h.responseText;
- self.html(h).find("script").each(function(){
- try {
- $.eval( this.text || this.textContent || this.innerHTML );
- } catch(e){}
- });
- if(f){f(h);}
- });
- return this;
+ // Create the request object
+ var xml = new XMLHttpRequest();
+
+ // Open the socket
+ xml.open(type || "GET", url, true);
+
+ // Set the correct header, if data is being sent
+ if ( data )
+ xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+
+ // Set header so calling script knows that it's an XMLHttpRequest
+ xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+
+ // Make sure the browser sends the right content length
+ if ( xml.overrideMimeType )
+ xml.setRequestHeader("Connection", "close");
+
+ // Wait for a response to come back
+ xml.onreadystatechange = function(){
+ // The transfer is complete and the data is available
+ if ( xml.readyState == 4 ) {
+ // Make sure that the request was successful
+ if ( jQuery.httpSuccess( xml ) ) {
+
+ // If a local callback was specified, fire it
+ if ( success ) success( xml );
+
+ // Fire the global callback
+ jQuery.event.trigger( "ajaxSuccess" );
+
+ // Otherwise, the request was not successful
+ } else {
+ // If a local callback was specified, fire it
+ if ( error ) error( xml );
+
+ // Fire the global callback
+ jQuery.event.trigger( "ajaxError" );
+ }
+
+ // The request was completed
+ jQuery.event.trigger( "ajaxComplete" );
+
+ // Handle the global AJAX counter
+ if ( ! --jQuery.ajax.active )
+ jQuery.event.trigger( "ajaxStop" );
+
+ // Process result
+ if ( ret ) ret(xml);
+ }
+ };
+
+ // Send the data
+ xml.send(data);