fnServerParams problem/question
fnServerParams problem/question
MPeter1975
Posts: 31Questions: 0Answers: 0
Hi,
Problem:
[code]
var oTable
var iPeriodStart; //
var iPeriodEnd; //
// Full Ajax Server-Side Processing
$(document).ready(function() {
oTable = $('#mytable').dataTable( {
// Ajax / Server Side
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/server_processing.php",
"fnServerParams" : function (aoData) {
aoData.push({
"name": "iPeriodStart",
"value": iPeriodStart
})
aoData.push({
"name": "iPeriodEnd",
"value": iPeriodEnd
})
},
[...]
});
$('#selectPeriods').submit( function() {
oTable.fnDraw(false);
iPeriodStart = 300;
return false;
});
});
[/code]
When the page first loads the iPeriodStart and iPeriodEnd variables are undefined in GET params. When I hit my own submit button the situation is the same, both parameters are undefined. When I hit my submit button again suddenly iPeriodStart becomes 300. Why only the third GET request contains the good value when the second one should have to?
Question: I have my own selectPeriods form with two select lists and one submit button. How can I pass the selected values to the iPeriodStart custom parameter?
Thanks!
Problem:
[code]
var oTable
var iPeriodStart; //
var iPeriodEnd; //
// Full Ajax Server-Side Processing
$(document).ready(function() {
oTable = $('#mytable').dataTable( {
// Ajax / Server Side
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/server_processing.php",
"fnServerParams" : function (aoData) {
aoData.push({
"name": "iPeriodStart",
"value": iPeriodStart
})
aoData.push({
"name": "iPeriodEnd",
"value": iPeriodEnd
})
},
[...]
});
$('#selectPeriods').submit( function() {
oTable.fnDraw(false);
iPeriodStart = 300;
return false;
});
});
[/code]
When the page first loads the iPeriodStart and iPeriodEnd variables are undefined in GET params. When I hit my own submit button the situation is the same, both parameters are undefined. When I hit my submit button again suddenly iPeriodStart becomes 300. Why only the third GET request contains the good value when the second one should have to?
Question: I have my own selectPeriods form with two select lists and one submit button. How can I pass the selected values to the iPeriodStart custom parameter?
Thanks!
This discussion has been closed.
Replies
[code]
$('#selectPeriods').submit( function() {
var sel1 = document.getElementById('periodStart');
var sel2 = document.getElementById('periodEnd');
iPeriodStart = sel1.options[sel1.selectedIndex].value;
iPeriodEnd = sel2.options[sel2.selectedIndex].value;
oTable.fnDraw(false);
return false;
});
[/code]
Allan