function Botleagues(){} Botleagues.url = 'https://api.local.botleagues.camilstaps.nl'; Botleagues.request = function(user_options, callback) { var options = { endpoint: null, method: 'GET', dataType: 'json', complete: function(data) { callback(data.responseJSON); } }; for (var name in user_options) { options[name] = user_options[name]; } var url = Botleagues.url + '/' + options['endpoint']; delete options['endpoint']; jQuery.ajax(url, options); }; Botleagues.redirect = function(user_options) { window.location = Botleagues.url + '/' + user_options['endpoint']; };