I'm trying to do an ajax request, code below, with mix datatable.js. But i don't find the glue.
let php_datas = '<?php echo $_path."|".json_encode($LNG). "|".json_encode($array_uzers)."|".$month ."|".$year."|".$membre."|".$user ."|".$debut_ts."|".$fin_ts."|".$get_payments ."|".json_encode($links_displayed); ?>';
let num_links = '<?php echo ($num_links + $nb_display_links); ?>';
let nb_display_links = '<?php echo ($nb_links + 500); ?>';
console.log(php_datas);
setTimeout(function(){
$.ajax({
url:'lib/ajx_List_link.php',
type: 'POST',
data: 'php_datas='+php_datas+'num_links='+num_links+'nb_links='+nb_display_links,
success: function (jsondatas) {
let links_displayed = jQuery.parseJSON(jsondatas);
for(let i = 0; i < links_displayed.length ;i++){
let table = $('#datatable-example').DataTable();
//links_displayed[i]["currency"]
let Row = "<tr id=''><td>"links_displayed[i]["checkbox"]"</td></tr>";
table.row.add(Row).draw( );
}
},
error: function(){
alert ('elle est où ma data ?');
}
});
}, 5000);
thanks a lot
I'm trying to do an ajax request, code below, with mix datatable.js. But i don't find the glue.
let php_datas = '<?php echo $_path."|".json_encode($LNG). "|".json_encode($array_uzers)."|".$month ."|".$year."|".$membre."|".$user ."|".$debut_ts."|".$fin_ts."|".$get_payments ."|".json_encode($links_displayed); ?>';
let num_links = '<?php echo ($num_links + $nb_display_links); ?>';
let nb_display_links = '<?php echo ($nb_links + 500); ?>';
console.log(php_datas);
setTimeout(function(){
$.ajax({
url:'lib/ajx_List_link.php',
type: 'POST',
data: 'php_datas='+php_datas+'num_links='+num_links+'nb_links='+nb_display_links,
success: function (jsondatas) {
let links_displayed = jQuery.parseJSON(jsondatas);
for(let i = 0; i < links_displayed.length ;i++){
let table = $('#datatable-example').DataTable();
//links_displayed[i]["currency"]
let Row = "<tr id=''><td>"links_displayed[i]["checkbox"]"</td></tr>";
table.row.add(Row).draw( );
}
},
error: function(){
alert ('elle est où ma data ?');
}
});
}, 5000);
thanks a lot
Share Improve this question edited Apr 20, 2018 at 9:58 Syfer 4,4993 gold badges22 silver badges38 bronze badges asked Apr 20, 2018 at 9:56 Alexandre MichonAlexandre Michon 291 gold badge1 silver badge1 bronze badge 8- 1 But, what is your question? – user9420984 Commented Apr 20, 2018 at 9:57
- 1 And where's the PHP? – Jonnix Commented Apr 20, 2018 at 9:58
- @JonStirling first two lines...some php – Jeff Commented Apr 20, 2018 at 10:00
- 4 Which line has the error? Is the error ing from PHP or JavaScript? Don't just dump a bunch of code here, be specific. – David Commented Apr 20, 2018 at 10:01
-
2
here's one error:
let Row = "<tr id=''><td>"links_displayed
- missing a+
– Jeff Commented Apr 20, 2018 at 10:02
1 Answer
Reset to default 2You forget the + for concatenation in your JS no ?
let Row = "<tr id=''><td>" + links_displayed[i]["checkbox"] + "</td></tr>";
Edit :
Andchange your data line in your ajax like this :
data: 'php_datas='+php_datas+'&num_links='+num_links+'&nb_links='+nb_display_links,