can you please help me. I'm developing a back-end app using laravel where I use data tables. The situation is I'm retrieving the mailing list from mailgun and wanted to return users in that mailing list. I'm using a html select tag from the laravel blade and wanted to refresh the data table by sending the mailing list as a parameter to the ajax request but nothing happens. I followed this question
https://datatables.net/forums/discussion/30286/ajax-reload-is-not-sending-updated-params
Below is my code
LARAVEL BLADE:
Mailing List: <select id="mailing-list">
@foreach($lists as $list)
@if($list->address == '[email protected]')
<option selected="selected" value="{{$list->address}}">{{$list->address}}</option>
@else
<option value="{{$list->address}}">{{$list->address}}</option>
@endif
@endforeach
</select>
DATA TABLE:
// get variable for mailing list
mailingListName = document.getElementById("mailing-list").value;
$('#mailing-list').change(function(){
table.ajax.reload();
});
// data table
var table = $('.data_Tables_wrapper').DataTable({
"bPaginate": true,
"bJQueryUI": true,
"iDisplayLength": 50,
"sPaginationType": "full_numbers",
"ajax": {
url: 'lists/data',
data: function ( d ) {
return JSON.stringify( d.mail = mailingListName );
}
},
"order": [ 2 ],
"columns": [
{ data:"email", name: "email" },
{ data:"name", name: "name" },
{ data:"subscribed", name: "subscribed" }
]
});
Any idea why the data table is not refreshing with the correct data.