Here is a basic skeleton of the function you are trying to make.
function AJAXCall(obj){
var type = obj.type || 'GET'; // 'GET' is the default here
// more variables...
$.ajax({
url: 'http://example.com',
type: type,
// more options...
});
}
Then you can call your function like so:
var options = {
type: 'POST'
// more options...
};
AJAXCall(options);
Here are the docs for $.ajax
, they may help: http://api.jquery.com/jQuery.ajax/