0
我有一個php文件,其中包含一個php語句,用於爲mySQL表名生成一個php會話變量。我需要訪問這個表名是一個JavaScript文件demo.js.任何想法都會很棒。在js文件中獲取php會話變量
PHP代碼剪斷-它:
$fcyclestartdate = $_POST['CycleStartDate'];
$fcycleenddate = $_POST['CycleEndDate'];
$_SESSION["paycycletable"] = "PCR_".str_replace("-", "", $fcyclestartdate)."_".str_replace("-", "", $fcycleenddate);
js文件的代碼剪斷-它:
function DatabaseGrid()
{
this.editableGrid = new EditableGrid("demo", {//Variable table name must go where "demo" is
enableSort: true,
// define the number of row visible by page
pageSize: 50,
// Once the table is displayed, we update the paginator state
tableRendered: function() { updatePaginator(this); },
tableLoaded: function() { datagrid.initializeGrid(this); },
modelChanged: function(rowIndex, columnIndex, oldValue, newValue, row) {
updateCellValue(this, rowIndex, columnIndex, oldValue, newValue, row);
}
});
this.fetchGrid();
}
你的JS文件將需要爲PHP執行,可能只是更改擴展名,然後使用'<?php echo $ _SESSION [「paycycletable」];在JS中代替演示。 – AbraCadaver
由於js文件中js函數的調用,這不起作用。 – NickMacWiz
這沒有任何意義... – AbraCadaver