aoData.push (syntax and params) I am confused.
aoData.push (syntax and params) I am confused.
AndyMan
Posts: 7Questions: 1Answers: 0
Hello,
I am able to open up a .csv "test.csv" in my datatables with no problem. however, I want to be able to pass the location of a file (csv) into the param string to a file that I have uploaded, but am having no results if I put in the whole url to the file..
How do I state the url/location of a file I have already uploaded to my server?...
Script snippet below..
var myVal = "test.csv" // This one works
var myVal = "http://myserver/myproj/server/php/files/test.csv"
$('#example').dataTable( {
"sScrollY":200,
"sScrollX": "100%",
"sScrollXInner": "110%",
"bProcessing" : true,
"bServerSide" : true,
"sAJaxSource": "getPage.php",
"fnServerParams": function ( aoData ) {
aoData.push( { name: "file", value: myVal } ); ***here is where I think I am going off the rails**
},
bFilter: false,
bSort: true
});
Andy
I am able to open up a .csv "test.csv" in my datatables with no problem. however, I want to be able to pass the location of a file (csv) into the param string to a file that I have uploaded, but am having no results if I put in the whole url to the file..
How do I state the url/location of a file I have already uploaded to my server?...
Script snippet below..
var myVal = "test.csv" // This one works
var myVal = "http://myserver/myproj/server/php/files/test.csv"
$('#example').dataTable( {
"sScrollY":200,
"sScrollX": "100%",
"sScrollXInner": "110%",
"bProcessing" : true,
"bServerSide" : true,
"sAJaxSource": "getPage.php",
"fnServerParams": function ( aoData ) {
aoData.push( { name: "file", value: myVal } ); ***here is where I think I am going off the rails**
},
bFilter: false,
bSort: true
});
Andy
This discussion has been closed.
Replies
I hope this is what you were looking for
Andy..
my "getPage.php"
<?PHP
require('CSVPager.php');
header('Content-type: application/json');
//echo $_REQUEST['file']; exit(0);
// If there is an error it will return this (just to make sure that something comes back...
$sFile = checkSet('file','old_test.csv',false);
//
$_POST['file'] //??
$csvPager = new CSVPager($sFile);
//Datatables Variables
$iDisplayStart = intval(checkSet('iDisplayStart', 0,false));
$iDisplayLength = intval(checkSet('iDisplayLength',10,false));
$iTotal = $csvPager->numberOfLines();
$bHeader = checkSet('returnheader',false);
$aOutput = array(
"sEcho" => intval(checkSet('sEcho','',false)),
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => $iTotal,
"aaData" => array()
);
$bHeader = $bHeader == 'false' || $bHeader == '0' || $bHeader == '' || $bHeader == null ? false : true;
$aOutput['aaData'] = $csvPager->getLines($iDisplayStart,$iDisplayLength,$bHeader);
echo json_encode($aOutput);
function checkSet( $var, $default = '', $toLower=true){
if( isset($_REQUEST[$var]) && $_REQUEST[$var] != '' ){
if( $toLower === true ){
return strtolower($_REQUEST[$var]);
}else{
return $_REQUEST[$var];
}
}
return $default;
}
?>