Its working for me like
$(function(){
$('#desig').selectize({
create:function (input, callback){
$.ajax({
url: "<?php echo $this->url(null, array('controller' => 'employee-detail', 'action' => 'add-new-desig-ajax'));?>",
type: 'POST',
data:{'designation':input},
success: function (result) {
if (result) {
// console.log('sdfasf',result);
callback({ value: result.id, text: input });
}
}
});
}
});
});
I have taken help from here
https://stackoverflow.com/questions/24366365/creating-an-item-if-not-already-exists-in-selectize-js-select-box-and-ajax-updat/46096111#46096111