Let's say I have:
var details = {
method: 'POST',
url: 'http://example.com/',
async: true,
params: {'param1': '1', 'param2': '2'},
headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT', 'Cache-Control': 'max-age=0'},
contentType: 'text'
};
kango.xhr.send(details, function(data) {
if (data.status == 200 && data.response != null) {
var text = data.response;
kango.console.log(text);
}
else { // something went wrong
kango.console.log('something went wrong');
}
});
Is there a way to wrap it more neatly somehow - like the only variables I really change is GET / POST, so I'm thinking something like:
call('POST', function(data) {});
Is this possible?
I'm not familiar enough with JS.