I have a PHP script that creates an object in PHP which is then used by jQuery after being ran through json_encode(). I've been trying to include a jQuery incline function in the PHP object that will work for my jQuery script after ran through json_encode, but I can't get it right.
For example, the PHP:
function get_columns_object() {
foreach( ... ) {
$columns[ $table ][] = array(
'data' => $name === 'cb' ? null : $name,
'title' => $header[ 'title' ],
'callback' => <<== HOW TO SPECIFY INLINE FN HERE?
);
}
}
Then, in the PHP script that outputs page HTML I include:
<script async>
var columns = <?php echo json_encode( get_columns_object() ); ?>;
</script>
This works fine for the variables, but how can I include a jQuery callback function and an inline jQuery function using this approach? Or can I? :S