I am currently having a problem with the jQuery Datatables plugin. The browser (IE7) my website is made for is having trouble handing the AJAX request. When I take the alert() out, it doesn't load the Datatables values I get form my PHP (json).
When I leave it in, it gives me the alert, but it also fills the table. Does anyone know a way to check if the ajax request was handled properly, and then proceed to fill the table?
It does work this way in Chrome and FireFox, but for some reason it doesn't in IE.
So: My browser (IE7) doesn't wait for the AJAX call to be handled, when I do not have an alert under the script.
Any help would be appreciated!
$(document).ready(function(){
$('#dataTables-example tfoot th.searchable').each( function () {
var title = $('#example thead th').eq( $(this).index() ).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );
var data = $.get("/kleurmixer/hmi/view_json2.php?type=2", function(data){
return data;
});
var table = $("#dataTables-example").DataTable(
{
"ajax" : {
"url" : "/kleurmixer/hmi/view_json2.php?type=2",
"dataSrc" : ''
},
"aoColumnDefs": [
{ 'bSortable': false, 'aTargets': [ 7 ] },
{ 'bSortable': false, 'aTargets': [ 8 ] }
]
}
);
table.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
$(".dataTables_filter").html("");
alert();
});