dimanche 1 décembre 2019

select2 I don't want to get data out of json

My script won't load any data in the Select2. I made data from laravel controller with response JSON data, this result json



  "results": [
    {
      "id": 1,
      "code": "11",
      "name": "jackson",
    },
    {
      "id": 2,
      "code": "12",
      "name": "michael,

    },

this my script code

$('.name_user').select2({
      width: "100%",
      placeholder: "Search...",
        ajax: {
          url: "",
          processResults: function(data) {
            return {
              results: $.map(data, function(obj) {
                return {
                  id: obj.id,
                  name: obj.name
                };
              })
            };
          },
          cache: true
        }

      });

How do I get data from route name_user?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire