How can I pass php variables from main page to the external php script.
How can I pass php variables from main page to the external php script.
audioperception
Posts: 3Questions: 3Answers: 0
// Here are the var's refering to the php variables that where previously defined:
var uid = <? echo $uid; ?>;
var casenumber = <? echo $casenumber; ?>;
var editor = new $.fn.dataTable.Editor( {
"ajax": "jnote/php/table.vekt6_copo_jnote.php",
"table": "#vekt6_copo_jnote",
"fields": [
{
"label": "Note",
"name": "note",
"type": "textarea"
}
]
} );
// Trying to set values to the php variables from the posting page.
Here is the php file:
$date = date_create();
$timestamp = date_format($date, 'Y-m-d H:i:s');
// DataTables PHP library and database connection
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'vekt6_copo_jnote', 'id' )
->fields(
Field::inst( 'timestamp' )
->setValue( $timestamp ),
Field::inst( 'case_juror' )
->setValue( $uid ),
Field::inst( 'case_number' )
->setValue( $casenumber ),
Field::inst( 'note' )
) ->where('case_number', $casenumber) ->where('case_juror', $uid)
->process( $_POST )
->json();
This discussion has been closed.
Answers
Did you ever find an answer to this? Currently working with something very similar.
For Editor, additional values can be sent to the server using
ajax.data
orpreSubmit
.For DataTables
ajax.data
orpreXhr
.Allan