Changeset 8359
- Timestamp:
- May 8, 2009, 3:02:22 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/javascript/transmission.remote.js
r8353 r8359 36 36 this._controller = controller; 37 37 this._error = ''; 38 this._token = ''; 38 39 }, 39 40 40 41 /* 41 42 * Display an error if an ajax request fails, and stop sending requests 43 * or on a 409, globally set the X-Transmission-Session-Id and resend 42 44 */ 43 ajaxError: function(request, error_string, exception ) {45 ajaxError: function(request, error_string, exception, ajaxObject) { 44 46 remote = this; 47 48 // set the Transmission-Session-Id on a 409 49 if(request.status == 409 && (token = request.getResponseHeader('X-Transmission-Session-Id'))){ 50 remote._token = token; 51 $.ajax(ajaxObject); 52 return; 53 } 54 45 55 remote._error = request.responseText 46 56 ? request.responseText.trim().replace(/(<([^>]+)>)/ig,"") … … 57 67 remote._controller.togglePeriodicRefresh(false); 58 68 }, 59 69 70 appendSessionId: function(XHR) { 71 XHR.setRequestHeader('X-Transmission-Session-Id', this._token); 72 }, 73 60 74 sendRequest: function( data, success ) { 61 75 remote = this; … … 67 81 cache: false, 68 82 data: $.toJSON(data), 69 error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception) }, 83 beforeSend: function(XHR){ remote.appendSessionId(XHR) }, 84 error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception, this) }, 70 85 success: success 71 86 } );
Note: See TracChangeset
for help on using the changeset viewer.