sonarr-repo-only/UI/Mixins/jquery.ajax.js

35 lines
895 B
JavaScript
Raw Normal View History

2013-02-22 05:56:46 +00:00
//try to add ajax data as query string to DELETE calls.
2013-06-22 06:24:24 +00:00
'use strict';
2013-06-21 05:35:56 +00:00
define(function () {
2013-02-15 23:38:53 +00:00
2013-06-21 05:35:56 +00:00
return function () {
2013-02-15 23:38:53 +00:00
2013-06-21 05:35:56 +00:00
var original = this.ajax;
this.ajax = function () {
2013-02-15 23:38:53 +00:00
2013-06-21 05:35:56 +00:00
var xhr = arguments[0];
2013-02-15 23:38:53 +00:00
2013-06-21 05:35:56 +00:00
//check if ajax call was made with data option
if (xhr && xhr.data && xhr.type === 'DELETE') {
2013-09-11 21:38:35 +00:00
if (!xhr.url.contains('?')) {
2013-06-21 05:35:56 +00:00
xhr.url = xhr.url + '?' + $.param(xhr.data);
}
else {
xhr.url = xhr.url + '&' + $.param(xhr.data);
}
delete xhr.data;
2013-02-15 23:38:53 +00:00
}
2013-09-20 07:31:02 +00:00
if (xhr) {
if (!xhr.headers) {
xhr.headers = {};
}
xhr.headers["ApiKey"] = window.NzbDrone.ApiKey;
}
2013-02-15 23:38:53 +00:00
2013-06-21 05:35:56 +00:00
return original.apply(this, arguments);
};
2013-02-15 23:38:53 +00:00
};
});