Save select2 tags via post to php

1

Hello, I'd like to know how I can send POST with tags selected in select2 (version 4). My code works fine, but I can not send the result of the selected tags to the server php , so none of them is saved.

The data is remote , which made my attempts even more difficult. The goal would be to pass the data via POST to php which would save them by separating the values by , Ex: valor1, valor dois, etc

I currently use x-editable with php to save the data, but my select2 used currently get the data dynamically and I could not integrate the two.

JSON DATA

{ "items": [{"text":"Meu Nome","id":"xyz05410"}]}

HTML

<select class="js-data-example-ajax" multiple="multiple"
style="width: 100%" class="form-control select2"></select>

JS

$(".js-data-example-ajax2").select2({
  ajax: {
    url: "get_data.php",
    dataType: 'json',
    delay: 250,
    data: function (params) {
      return {
        term: params.term // search term
      };
    },
    processResults: function (data, page) {
      return {
        results: data.items
      };
    },
    cache: true
  },
  //tags: true,
  theme: "bootstrap",
  tokenSeparators: [","],
  allowClear: true,
  placeholder: 'Insert tags',

  escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
  minimumInputLength: 3,
  templateResult: formatRepo, // omitted for brevity, see the source of this page
  templateSelection: formatRepoSelection // omitted for brevity, see the source of this page
});
  

Is there any way to save the selected tags from select2 ( v4 ) in php ?

    
asked by anonymous 06.09.2015 / 13:45

0 answers