Commit c46e6e98 authored by tom's avatar tom

Return jqxhr object from ajax request

Not the context of the request
parent e83d6b94
...@@ -78,27 +78,24 @@ ...@@ -78,27 +78,24 @@
} }
delete args.data; delete args.data;
$.extend(args, {statusCode: statusCode}); $.extend(args, {statusCode: statusCode});
return this.each(function () { var ajaxOptions = {
var ajaxOptions = { type: type,
type: type, url: $(this).slapos('host') + method,
url: $(this).slapos('host') + method, contentType: 'application/json',
contentType: 'application/json', data: JSON.stringify(data),
//cache: false, datatype: 'json',
data: JSON.stringify(data), context: $(this),
datatype: 'json', headers: {
context: $(this), 'Accept': 'application/json',
headers: { },
'Accept': 'application/json', beforeSend: function (xhr) {
}, if ($(this).slapos('access_token')) {
beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', $(this).slapos('store', 'token_type') + ' ' + $(this).slapos('access_token'));
if ($(this).slapos('access_token')) { }
xhr.setRequestHeader('Authorization', $(this).slapos('store', 'token_type') + ' ' + $(this).slapos('access_token')); }
} };
} $.extend(ajaxOptions, args);
}; return $.ajax(ajaxOptions);
$.extend(ajaxOptions, args);
$.ajax(ajaxOptions);
});
}, },
instanceList: function (args) { instanceList: function (args) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment