Changeset 32747
- Timestamp:
- 06/13/2015 02:29:42 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/wp-util.js
r31471 r32747 51 51 * @param {string} action The slug of the action to fire in WordPress. 52 52 * @param {object} data The data to populate $_POST with. 53 * @return {$.promise} A jQuery promise that represents the request. 53 * @return {$.promise} A jQuery promise that represents the request, 54 * decorated with an abort() method. 54 55 */ 55 56 post: function( action, data ) { … … 66 67 * @param {string} action The slug of the action to fire in WordPress. 67 68 * @param {object} options The options passed to jQuery.ajax. 68 * @return {$.promise} A jQuery promise that represents the request. 69 * @return {$.promise} A jQuery promise that represents the request, 70 * decorated with an abort() method. 69 71 */ 70 72 send: function( action, options ) { 73 var promise, deferred; 71 74 if ( _.isObject( action ) ) { 72 75 options = action; … … 82 85 }); 83 86 84 return$.Deferred( function( deferred ) {87 deferred = $.Deferred( function( deferred ) { 85 88 // Transfer success/error callbacks. 86 89 if ( options.success ) … … 93 96 94 97 // Use with PHP's wp_send_json_success() and wp_send_json_error() 95 $.ajax( options ).done( function( response ) {98 deferred.jqXHR = $.ajax( options ).done( function( response ) { 96 99 // Treat a response of `1` as successful for backwards 97 100 // compatibility with existing handlers. … … 106 109 deferred.rejectWith( this, arguments ); 107 110 }); 108 }).promise(); 111 }); 112 113 promise = deferred.promise(); 114 promise.abort = function() { 115 deferred.jqXHR.abort(); 116 return this; 117 }; 118 119 return promise; 109 120 } 110 121 };
Note: See TracChangeset
for help on using the changeset viewer.