0
I have the following html combobox:
<div class="form-group col-lg-6 row">
{{ Form::select( 'state',array( 0 => '' ),null, array( 'class' => 'form-control', 'data-placeholder' => 'State','id' => 'state' ) ) }}
</div>
I’d like to populate it with the Bootstrap + Chosen with the following jquery block:
$(document).ready( function () {
var token = $('#token').val();
var estados = $('#state');
$.ajax({
url : './estados',
dataType : 'json',
type : 'post',
data : {
_token : token
},
success : function ( data ) {
estados.find('option').remove();
estados.append( $('<option>').val( 0 ).text( '' ));
//console.log( data );
$.each(data, function (i, j) {
console.log( j.descricao );
var option = $('<option>').val( j.sigla ).text( j.descricao ) ;
estados.append( option );
});
estados.trigger('chosen:updated');
}
});
});
But nothing happens. Since console.log displays the data normally.
In direct PHP I get popular, but I would like to use in Laravel.
tried it like this
$.ajaxSetup({ cache: false });
– Felipe Deolindo
What is the cache : false ?
– adventistaam
When setting the property of the false cache jQuery will attach a date/time stamp to the URL, then the browser does not cache it (as the URL is unique to each request), if in the console it is saying that it worked, sometimes the browser is cached in the information
– Felipe Deolindo
Didn’t work either
– adventistaam
It only works if I bring it straight from the controller
– adventistaam
Even using <select><option> doesn’t work
– adventistaam
Nothing? I haven’t figured it out yet
– adventistaam
I was able to fill in via jquery
– adventistaam