-
- /**
- * Load a remote page using an HTTP request. This function is the primary
- * means of making AJAX requests using jQuery. $.ajax() takes one property,
- * an object of key/value pairs, that're are used to initalize the request.
- *
- * These are all the key/values that can be passed in to 'prop':
- *
- * (String) type - The type of request to make (e.g. "POST" or "GET").
- *
- * (String) url - The URL of the page to request.
- *
- * (String) data - A string of data to be sent to the server (POST only).
- *
- * (String) dataType - The type of data that you're expecting back from
- * the server (e.g. "xml", "html", "script", or "json").
- *
- * (Boolean) ifModified - Allow the request to be successful only if the
- * response has changed since the last request, default is false, ignoring
- * the Last-Modified header
- *
- * (Number) timeout - Local timeout to override global timeout, eg. to give a
- * single request a longer timeout while all others timeout after 1 seconds,
- * see $.ajaxTimeout
- *
- * (Boolean) global - Wheather to trigger global AJAX event handlers for
- * this request, default is true. Set to true to prevent that global handlers
- * like ajaxStart or ajaxStop are triggered.
- *
- * (Function) error - A function to be called if the request fails. The
- * function gets passed two arguments: The XMLHttpRequest object and a
- * string describing the type of error that occurred.
- *
- * (Function) success - A function to be called if the request succeeds. The
- * function gets passed one argument: The data returned from the server,
- * formatted according to the 'dataType' parameter.
- *
- * (Function) complete - A function to be called when the request finishes. The
- * function gets passed two arguments: The XMLHttpRequest object and a
- * string describing the type the success of the request.
- *
- * @example $.ajax({
- * type: "GET",
- * url: "test.js",
- * dataType: "script"
- * })
- * @desc Load and execute a JavaScript file.
- *
- * @example $.ajax({
- * type: "POST",
- * url: "some.php",
- * data: "name=John&location=Boston",
- * success: function(msg){
- * alert( "Data Saved: " + msg );
- * }
- * });
- * @desc Save some data to the server and notify the user once its complete.
- *
- * @test stop();
- * $.ajax({
- * type: "GET",
- * url: "data/name.php?name=foo",
- * success: function(msg){
- * ok( msg == 'bar', 'Check for GET' );
- * start();
- * }
- * });
- *
- * @test stop();
- * $.ajax({
- * type: "POST",
- * url: "data/name.php",
- * data: "name=peter",
- * success: function(msg){
- * ok( msg == 'pan', 'Check for POST' );
- * start();
- * }
- * });
- *
- * @test stop();
- * foobar = undefined;
- * foo = undefined;
- * var verifyEvaluation = function() {
- * ok( foobar == "bar", 'Check if script src was evaluated for datatype html' );
- * start();
- * };
- * $.ajax({
- * dataType: "html",
- * url: "data/test.html",
- * success: function(data) {
- * ok( data.match(/^html text/), 'Check content for datatype html' );
- * ok( foo == "foo", 'Check if script was evaluated for datatype html' );
- * setTimeout(verifyEvaluation, 600);
- * }
- * });
- *
- * @test stop();
- * $.ajax({
- * url: "data/with_fries.xml", dataType: "xml", type: "GET", data: "", success: function(resp) {
- * ok( $("properties", resp).length == 1, 'properties in responseXML' );
- * ok( $("jsconf", resp).length == 1, 'jsconf in responseXML' );
- * ok( $("thing", resp).length == 2, 'things in responseXML' );
- * start();
- * }
- * });
- *
- * @name $.ajax
- * @type jQuery
- * @param Hash prop A set of properties to initialize the request with.
- * @cat AJAX
- */
- ajax: function( type, url, data, ret, ifModified ) {
- // If only a single argument was passed in,
- // assume that it is a object of key/value pairs
- var global = true;
- var timeout = jQuery.timeout;
- if ( !url ) {
- ret = type.complete;
- var success = type.success;
- var error = type.error;
- var dataType = type.dataType;
- var global = typeof type.global == "boolean" ? type.global : true;
- var timeout = typeof type.timeout == "number" ? type.timeout : jQuery.timeout;
- var ifModified = type.ifModified || false;
- data = type.data;
- url = type.url;
- type = type.type;
+
+ ajax: function( s ) {
+ var jsonp, jsre = /=(\?|%3F)/g, status, data;
+
+ // 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));
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data != "string" )
+ s.data = jQuery.param(s.data);
+
+ // Break the data into one single string
+ var q = s.url.indexOf("?");
+ if ( q > -1 ) {
+ s.data = (s.data ? s.data + "&" : "") + s.url.slice(q + 1);
+ s.url = s.url.slice(0, q);