I have this script which works fine but i want it to move to common js file.
function commonSelect2(selector,url,id,text){
    selector.select2({
        minimumInputLength:1,
        placeholder:"Select Parent Menu",
        ajax: {
            type:"post",
            url: url,
            dataType: 'json',
            quietMillis: 100,
            data: function(term, page) {
                return {
                    term: term, //search term
                    page_limit: 10 // page size
                };
            },
            results: function(data, page ) {
                var newData = [];
                $.each(data, function (index,value) {
                    newData.push({
                        id: value.id,  //id part present in data
                        text: value.text  //string to be displayed
                    });
                });
                return { results: newData };
            }
        }
    });
}
mostly it is done except the part of id and text parameter.
Here is how i send parameters
var selector = $('#selectParentMenu');
var url = "{{base_url()}}admin/configurations/loadAllParentFormNames/";
var id = "FormID";
var text = "FormName";
commonSelect2(selector,url,id,text);
problem is that
id: value.id,  //id part present in data
text: value.text  //string to be displayed
the value.id and value.text do not recognize the id and text is of parameters.
it works if i do like this
id: value.FormID,  //id part present in data
text: value.FormName  //string to be displayed
but if i put parameters containing these values don't work.
 
     
    