$('select.econCountry').select2({
  width: '200px',
  ajax: {
    url: '/ajax/get/countries',
    dataType: 'json',
    type: "GET",
    data: function (params) {
      var query = {
        filter: params.term
      }

      // Query parameters will be ?search=[term]&type=public
      return query;
    },
    processResults: function (data) {
      // Transforms the top-level key of the response object from 'items' to 'results'
      var data = $.map(data, function (obj) {
        obj.text = obj.text || obj.name; // replace pk with your identifier
        return obj;
      });
      return {
        results: data
      };
    }
  }
});
$('select.econCounty').select2({
  width: '200px',
  ajax: {
    url: '/ajax/get/counties',
    dataType: 'json',
    type: "GET",
    data: function (params) {
      var query = {
        filter: params.term
      }

      // Query parameters will be ?search=[term]&type=public
      return query;
    },
    processResults: function (data) {
      // Transforms the top-level key of the response object from 'items' to 'results'
      var data = $.map(data, function (obj) {
        obj.text = obj.text || obj.name; // replace pk with your identifier
        return obj;
      });
      return {
        results: data
      };
    }
  }
});
$('select.econCity').select2({
  width: '200px',
  ajax: {
    url: '/ajax/get/cities',
    dataType: 'json',
    type: "GET",
    data: function (params) {
      var query = {
        filter: params.term
      }

      // Query parameters will be ?search=[term]&type=public
      return query;
    },
    processResults: function (data) {
      // Transforms the top-level key of the response object from 'items' to 'results'
      var data = $.map(data, function (obj) {
        obj.id = obj.id || obj.zip;
        obj.text = obj.text || obj.city; // replace pk with your identifier
        obj.text = obj.text+" - "+obj.id;
        return obj;
      });
      console.log(data);
      return {
        results: data
      };
    }
  }
});
$('select.econPartner').select2({
  width: '200px',
  ajax: {
    url: '/ajax/get/partner',
    dataType: 'json',
    type: "GET",
    data: function (params) {
      var query = {
        filter: params.term
      }

      // Query parameters will be ?search=[term]&type=public
      return query;
    },
    processResults: function (data) {
      // Transforms the top-level key of the response object from 'items' to 'results'
      var data = $.map(data, function (obj) {
        obj.id = obj.id || obj.id;
        obj.text = obj.text || obj.partnerName; // replace pk with your identifier
        obj.text = obj.text;
        return obj;
      });
      console.log(data);
      return {
        results: data
      };
    }
  }
});
$('button.savedata').on('click',function(e){
  var allAttributes = jQuery('input.form-control,select.form-control').map(function() { /* example: .class */
    let record = {key:$(this).attr('name'),value:$(this).val()};
    return record; /* example: id */ 
  }).get();
  $("#sendForm").submit();
});