select2 ajax selected value

Solutions on MaxInterview for select2 ajax selected value by the best coders in the world

showing results for - "select2 ajax selected value"
Nawel
08 Jan 2018
1$('#payment_method').select2({
2	placeholder: 'Select a option',
3	ajax: {
4			url: 'ajax_get_url',
5            dataType: 'json',
6            type: 'GET',
7            processResults({ data }) {
8				return {
9					results: $.map(data, function (item) {
10						return {
11							text: item.name,
12                            id: item.id,
13                            }
14						})
15					}
16				}
17			}
18		});
Roberta
19 Jun 2020
1//YOUR AJAX SELECT2
2$("#myselect2").select2({
3    dropdownParent: $('#test_modal'),
4    width: '100%',
5    placeholder: 'Seach',
6    ajax: {
7        url: "<?=base_url('dashboard/api/v1/dropdown')?>",
8        dataType: 'json',
9        delay: 250,
10        processResults: function(data) {
11            return {
12                results: data
13            };
14        },
15        cache: true
16    }
17});
18
19
20// TRIGGER EDIT AND SET THE VALUE FOR SPECIFIC MODAL / FORM
21$(document).on('click', '.edit_button', function() {
22    var something_id = $('#something_id').val();
23    $.ajax({
24        url: "<?php echo base_url('dashboard/api/v1/page/edit');?>" + "/" + something_id,
25        method: 'POST',
26        dataType: 'json',
27        success: function(data) {
28            if (data.id) {
29                // Set selected   
30                var $newOption = $("<option selected='selected'></option>").val(data.id).text(data.text);
31                $("#myselect2").append($newOption).trigger('change');
32            } else {
33                $('#myselect2').val(null).trigger('change');
34            }
35        }
36    });
37});
queries leading to this page
select2 search load moreselect2 trigger ajax after typingselect2 ajax lazy loadselect2 ajax pre selectselect2 ajax request triggerred on clickselect 2 ajax dont select typingget data from ajax with select 2select2 server 3a falseget value of ajax select2select 2 multiple ajax data jquery select2 min response successelect2 with ajaxget all results ajax select2boostrap select 2 ajaxselect 2 ajax searchexecute selec2 ajax on openingselect2 v4 ajaxselect2 ajax methodhow to enable select2 when we receive some selection box data from server in php jqueryselect2 ajax on searchselect2 pagingjs select2 ajaxselect2 ajax response no results drupal 8select2 ajax server sideselect2 data remote jsonsearch is not working select2ajax select2 linkselect2 send json inside varscroll dropdown in select2 jquery with ajax call select2 ajax thenselect2 load data from javascriptselect2 ajax and multiselectselect2 ajax sourcejquery datatable ajax post select2 parametersselect 2 more ajax data select 2 multiple ajaxselect2 ajax processresults orderselect2 selected value ajaxselect2 remote json search in loaded dataselect2 with pagesselect2 dynamic data ajax select2 ajax selected valueselect2 ajax postselect2 data ajax searchselect2 ajax example divselect2 typeahead examplefiltering select2ajax select2select 2 ajax versionselect2 append remote jsonselect2 ajaxselect2 query exampleselect2 intailze with ajaxselect2 load data from ajaxmulti select select2 ajaxselect2 ajax response step by stepselect2 inside ajaxselect2 processresultscustom url set in select2select2 server side searchselect2 html ajaxget value from select2 ajaxselect2 multiple ajax searchselect2 ajax with query dataselect ajax minimum inputselect2 data from ajaxselect 2 jquery example with ajaxsearch in select2select2 live searchselect2 data ajax methodinfinite scroll select2 ajax jqueryselect2 ajax exampleselect2 send extra data with search paramsselect2 ajax loadselect2 on request successselect2 autocomplete without ajaxjquery select2 autocompleteselect 2 in queryselect2 ajax searchselect2 search server sideselect2 ajax on seectselect2 search with ajax processresults 3a function 28data 29 ajax select 2select2 ajax no data selectedselect2 assign the value ajax responseselect2 ajax jqueryselect2 search ajaxselect2 selct box with input ajax searchselect 2 search not workingselect2 on change server 3a falseshow 10 record in select2 autocompleteselect2 ajax example php editselect 2 on ajax htmljs select2 async searchselect2 ajaselect 2 ajaxselect2 ajax server side custom parameterselect2 processresults inside another ajax functionselect2 return html from server sideselect2 ajax load external dataselect2 server side exampleautocomplete select2processresults 3a function 28data 29select 2 autocompleteselect2 server side set valueselect2 ajax search filterselect2 search ajax selected valueselect2 ajax term queryselect value on ajax select2select 2 inside existing ajax callchange select2 from ajax select2select2 server side examplsselect2 paging using ajax urlselect2 no show results until introducedselect 2 ajax optioncall ajax on scroll select2load select2 values json ajax based on other select2 valueselect2 json examplejs select2 multi select ajaxselect2 autocomplete with ajaxselect2 ajax add results to list optionsselect2 type 3dqueryjquery datatable ajax pass select2 parametersselect 2 multiselect not opening search barselect2 delayselect2 ajax defaultselect 2 with ajaxselect2 ajax valueselect2 data filterselect2 ajax dropdownlist optionselect2 return message ajaxselect2 ajax paramsselect2 on select ajaxselect 2 with existing ajax callselect2 server sidejquery get multiple select2 selected value from remote sourcejavascript select2 trigger ajaxselect2 suggest onlynodejs select2 server side filteringselect2 ajax response limit number of recordsajax select2 searchselect2 data ajaxselect2 success this elementselect2 json data exampleselect2 load data ajaxselect2 type 3dqueryselect2 search after stop typingjavascript select2 trigger ajax callinfinite scroll select2 ajaxdropdown select 2 ajax return datashowing results after clearing the search string in select2select2 multiple jquery ajaxselect2 server search eventajax response for select2 3fselect2 on change server filter falseset value select 2 ajaxselect2 2b ajaxselect2 ajax jquery postbinding the data from ajax to select 2 drop downselect2 paramsselect 2 input type selectbox ajax exampleselect2 ajaxselect2 on search call ajaxselect2 inside ajax callwhen select2 option then ajax dont workjavascript searchterm 3a params termselect 2 output in querybootstrap multiple select with search subtext californiaselect2 ajax request parametersselect 2 ajax showing search term in resultselect2 ajax data sourceselect 2 data frome databaseselect2 data loadresponse select 2 multiselectselect 2 ajax callselect2 fill with ajaxselect2 populate with ajax on clickset selected value select2 ajaxselect2 before ajaxjquery ajax remoteselec2 filter dataselect2 load data from json ajaxload select2 values json ajax based on another select2 valueselect2 drop down php jsonselect 2 ajax bootstrap4select2 ajax on selectselect2 params termselect2 json data exampleselect2 ajax search termselect2 searchselect2 ajax selected value