This topic contains 1 reply, has 2 voices, and was last updated by Sean Sean 2 years, 5 months ago.

How to use remote date by select2


  • sulgraphica
    Participant

    Posts: 4
    Member Reply #4122

    Hi I am attempting to do an AJAX call with the Select2 ver4 jquery plugin and Using Loading remote data of Select2. But i got an errot and took a screenshot. Please help me.

    html.code (components_select2.html)

    
    <select class="js-data-example-ajax2">
     <option selected="selected" value="3620194">select2/select2</option>
    </select>
    

    js.code (components-select2.js)

    
    $(".js-data-example-ajax2").select2({
     width: "off",
      ajax: {
       url: "./json.php",
       dataType: 'json',
       delay: 250,
       data: function(params) {
        return {
         q: params.term, // search term
         page: params.page
        };
       },
       processResults: function(data, page) {
        // parse the results into the format expected by Select2.
        // since we are using custom formatting functions we do not need to
        // alter the remote JSON data
        return {
         results: data.items
        };
       },
       cache: true
      }
     });
    
    • This topic was modified 2 years, 5 months ago by  sulgraphica.
    • This topic was modified 2 years, 5 months ago by  sulgraphica.
    Attachments:
    You must be logged in to view attached files.
    Sean
    Sean
    Keymaster

    Posts: 4444
    Support Staff Reply #4134

    Hi,

    Sorry, our support does not cover 3rd party plugins. You can check select2 plugin’s official documentation in order to learn more: https://select2.github.io

    Thanks.

Tagged: 

You must be logged in to reply to this topic.