मैं AJAX के साथ Select2 (नीचे कोड) का उपयोग कर रहा साथ डालने के बाद:सेट डेटा AJAX
$(".select2-ajax").select2({
placeholder: "Search user",
minimumInputLength: 1,
ajax: {
url: $('#url-search-client').val(),
dataType: 'json',
type: 'post',
data: function (term, page) {
return {
filter: term
};
},
results: function (data, page) {
return {results: data};
}
},
width : '50%',
formatInputTooShort: function() {return 'Informe mais caracteres'; },
formatResult: formatResultSelectAjax, // omitted for brevity, see the source of this page
formatSelection: formatSelectAjaxValue, // omitted for brevity, see the source of this page
dropdownCssClass: "bigdrop" // apply css that makes the dropdown taller
});
ठीक है, नहीं तो ग्राहक मिल गया है, उपयोगकर्ता एक मॉडल को खोलने के लिए एक बटन का उपयोग किया जा सकता है और नया क्लाइंट जोड़ें, संभव है कि नए ग्राहक के रिटर्न (आईडी और नामे के साथ जेसन) का उपयोग करें और चयनित डेटा के रूप में डेटा (जैसे नाम) को चुनें।
$('.btn-form-client').click(function() {
$.ajax({
url: $('#frm-client').attr('action'),
dataType: 'json',
type: 'post',
data: $('#frm-client').serialize()
}).done(function (data) {
$('#modal-client').modal('hide')
});
return false;
});
क्या आप यह काम कर सकते हैं? – Sebastialonso