Closed s3325238 closed 5 years ago
Here is console log in case you need it
btw, my purchase email for this product is: leonguyen0202@gmail.com
Moreover, I also leave a comment inside this product page via your website
Hello @s3325238,
Thank you for using our products, due to I don't have any experience with Ajax, I can direct you to these references: https://stackoverflow.com/questions/43515919/loading-bootstrap-select-picker-using-ajax https://developer.snapappointments.com/bootstrap-select/
Best, Stefan
Hello team,
As the title said, I have that problem. I can fetch the data from laravel controller perfectly and can also console log the data. However, I cannot see the option tag within select.
This is my code for select option:
<div class="col-md-12">
<div class="row">
<label class="col-sm-2 col-form-label">Role</label>
<div class="col-sm-8">
<div class="form-group">
<select class="selectpicker" name="roleSelect" id="roleSelect" data-size="10" data-style="btn btn-primary btn-round" title="Role required" required="true">
<option disabled selected>Select role</option>
</select>
</div>
</div>
<label class="col-sm-2 label-on-right">
Some text
</label>
</div>
</div>
And this is the code from ajax within the page
var formOption = "" ;
var mySelect = $('#roleSelect');
$.ajax({
url:'{!! route('api.role.data') !!}',
method:'get',
// dataType:'json',success:function (role) {
// alert(role) // $('#defaultRole').val(role.role_name)$.each(role,function (index,roleData) {
$("#roleSelect").append('<option value='+roleData.id+'>'+roleData.role_name+'</option>');
// formOption += ""; // Data load successfull - problem with append to select tag});
// mySelect.html(formOption);console.log($('#roleSelect'));
// alert(formOption);}
});
API code:$roles = Role::All();
return $roles;
I also include the evidence of page loading. Please help me.