"data" from ajax request
"data" from ajax request
phlex
Posts: 7Questions: 2Answers: 0
Im using standard ajax request from and example on this site. In my php file it looks like this:
$columns = array(
array( 'db' => 'Namirnica_100_grama', 'dt' => 1 ),
array( 'db' => 'kcal', 'dt' => 2 ),
array( 'db' => 'UH', 'dt' => 3 ),
array( 'db' => 'Masti', 'dt' => 5 ),
array( 'db' => 'Proteini', 'dt' => 4 ),
array( 'db' => 'Kategorija', 'dt' => 6 ),
array( 'db' => 'link', 'dt' => 7 ),
array( 'db' => 'branded', 'dt' => 8 ),
);
For filtering i use something like this
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var result = true;
if(kcaltoRange < data[2]){
result = false;
}
if(kcalfromRange > data[2]){
result = false;
}
if(uhtoRange < data[3]){
result = false;
}
....ect
Ajax request returns this:
{draw: 0, recordsTotal: 4029, recordsFiltered: 4029, data: [,…]}
data: [,…]
[0 … 99]
0: {1: "Senf sa zrncima Maille", 2: "18", 3: "0.0", 4: "0.0", 5: "0.0", 6: "Ulja, umaci i preljevi",…}
1: "Senf sa zrncima Maille"
2: "18"
3: "0.0"
4: "0.0"
5: "0.0"
6: "Ulja, umaci i preljevi"
7: "#Test-link"
8: "yes"
So the issue Im having here is that data[8] does not exist in this scope and i need that data to filter the page. So how do i get it? or is there another way to filter it?
note: i dont need to show/render this data to user, its only supposed to be used for filtering.
This discussion has been closed.
Answers
Oh the filter was supposed to be like
Solved, used
table.row(dataIndex).data()[8] =="yes"