$.ajaxResponse = {};
var CallAPI = function(){

  if (arguments.length < 2) {
    return false;
  }
  var ajax_url = arguments[0];
  var method = arguments[1];
  var post_data = typeof arguments[2] !== 'undefined' ? arguments[2] : null;
  var data_type = typeof arguments[3] !== 'undefined' ? arguments[3] : 'text';
  var callback_function = typeof arguments[4] !== 'undefined' ? arguments[4] : null;
  var header = typeof arguments[5] !== 'undefined' ? arguments[5] : null;
  var content_type = arguments[6];

  var jqXHR = $.ajax({
    async: false,
    url: ajax_url,
    type: method,
    contentType: content_type,
    headers: header,
    data: JSON.stringify(post_data),
    dataType: data_type,
    cache: false,
    beforeSend: function(xhr, set) {
    // return;
    }
  });

  jqXHR.done(function(data, stat, xhr) {
    if ('script' !== data_type) {
      $.ajaxResponse = { 'responseText': jqXHR.responseText, 'status': jqXHR.status, 'statusText': jqXHR.statusText, 'responseJSON': jqXHR.responseJSON };
    } else {
      return data;
    }
    if ('' !== callback_function) {
      return Callback[callback_function]();
    }
  });

  jqXHR.fail(function(xhr, stat, err) {
    if ('script' !== data_type) {
      $.ajaxResponse = { 'responseText': jqXHR.responseText, 'status': jqXHR.status, 'statusText': jqXHR.statusText, 'responseJSON': jqXHR.responseJSON };
    } else {
      return data;
    }
    if ('' !== callback_function) {
      return Callback[callback_function]();
    }
  });

  jqXHR.always(function(res1, stat, res2) {
    if (stat === 'success') {
      //
    }
  });

};
