jQuery+JavaScript: Create custom ajax call function with single object as argument [closed]

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...
    url: 'http://example.com',
    type: type,
    // more options...

Then you can call your function like so:

var options = {
  type: 'POST'
  // more options...

Here are the docs for $.ajax, they may help: http://api.jquery.com/jQuery.ajax/

Browse More Popular Posts

Leave a Comment