I have created a ajax script to add records to DB and now want to update the chosen dropdown to see the records without refreshing the page ..
I have
<script type="text/javascript">
$(document).ready(function(){
$("#sky-inchidere").submit(function(e){
e.preventDefault();
var tdata= $("#sky-inchidere").serializeArray();
$.ajax({
type: "POST",
url: 'http://localhost/new/oportunitati/add',
data: tdata,
success:function(tdata)
{
// close the modal
$('#myModal').modal('hide');
// update dropdown ??
$('.chosen-select').trigger('liszt:updated');
},
error: function (XHR, status, response) {
alert('fail');
}
});
});
});
</script>
I have tried :
$('.chosen-select').trigger('liszt:updated');
$('#field-beneficiar_p').trigger('chosen:updated');
$('field-beneficiar_p').trigger('liszt:updated');
The field name is :
<select id='field-sectiune_p' name='sectiune_p' class='chosen-select' data-placeholder='Selecteaza Categorie'>
any suggestions ?
