Rename wp.xhr to wp.ajax to match admin-ajax.php (which it uses), jQuery.ajax (which it wraps), etc. see #24424.

git-svn-id: http://core.svn.wordpress.org/trunk@24652 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-07-11 00:20:36 +00:00
parent 031d959efd
commit 721f7ba271
4 changed files with 13 additions and 13 deletions

View File

@ -207,7 +207,7 @@ window.wp = window.wp || {};
post_id: revisions.settings.postId post_id: revisions.settings.postId
}); });
var deferred = wp.xhr.send( options ); var deferred = wp.ajax.send( options );
var requests = this.requests; var requests = this.requests;
// Record that we're requesting each diff. // Record that we're requesting each diff.

View File

@ -101,17 +101,17 @@ window.wp = window.wp || {};
* media.post( [action], [data] ) * media.post( [action], [data] )
* *
* Sends a POST request to WordPress. * Sends a POST request to WordPress.
* See wp.xhr.post() in `wp-includes/js/wp-util.js`. * See wp.ajax.post() in `wp-includes/js/wp-util.js`.
*/ */
post: wp.xhr.post, post: wp.ajax.post,
/** /**
* media.ajax( [action], [options] ) * media.ajax( [action], [options] )
* *
* Sends an XHR request to WordPress. * Sends an XHR request to WordPress.
* See wp.xhr.send() in `wp-includes/js/wp-util.js`. * See wp.ajax.send() in `wp-includes/js/wp-util.js`.
*/ */
ajax: wp.xhr.send, ajax: wp.ajax.send,
// Scales a set of dimensions to fit within bounding dimensions. // Scales a set of dimensions to fit within bounding dimensions.
fit: function( dimensions ) { fit: function( dimensions ) {

View File

@ -28,16 +28,16 @@ window.wp = window.wp || {};
}; };
}); });
// wp.xhr // wp.ajax
// ------ // ------
// //
// Tools for sending ajax requests with JSON responses and built in error handling. // Tools for sending ajax requests with JSON responses and built in error handling.
// Mirrors and wraps jQuery's ajax APIs. // Mirrors and wraps jQuery's ajax APIs.
wp.xhr = { wp.ajax = {
settings: settings.xhr || {}, settings: settings.ajax || {},
/** /**
* wp.xhr.post( [action], [data] ) * wp.ajax.post( [action], [data] )
* *
* Sends a POST request to WordPress. * Sends a POST request to WordPress.
* *
@ -46,13 +46,13 @@ window.wp = window.wp || {};
* @return {$.promise} A jQuery promise that represents the request. * @return {$.promise} A jQuery promise that represents the request.
*/ */
post: function( action, data ) { post: function( action, data ) {
return wp.xhr.send({ return wp.ajax.send({
data: _.isObject( action ) ? action : _.extend( data || {}, { action: action }) data: _.isObject( action ) ? action : _.extend( data || {}, { action: action })
}); });
}, },
/** /**
* wp.xhr.send( [action], [options] ) * wp.ajax.send( [action], [options] )
* *
* Sends a POST request to WordPress. * Sends a POST request to WordPress.
* *
@ -70,7 +70,7 @@ window.wp = window.wp || {};
options = _.defaults( options || {}, { options = _.defaults( options || {}, {
type: 'POST', type: 'POST',
url: wp.xhr.settings.url, url: wp.ajax.settings.url,
context: this context: this
}); });

View File

@ -269,7 +269,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array('underscore', 'jquery'), false, 1 ); $scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array('underscore', 'jquery'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array( did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array(
'xhr' => array( 'ajax' => array(
'url' => admin_url( 'admin-ajax.php', 'relative' ), 'url' => admin_url( 'admin-ajax.php', 'relative' ),
), ),
) ); ) );