This is my php code:
<?php
$typeid = 65;
$subledgerid = 'subledger'.$typeid;
$loadledger = 'loadledgers';
?>
<script type="text/javascript">view_subledger('<?php echo $subledgerid;?>',<?php echo $typeid;?>,'<?php echo $loadledger;?>');</script>
This is not calling the view_subledger().
But when i call something like this it will work fine:
<script type="text/javascript">view_subledger('subledger65',65,'loadledgers');</script>
How can i call this?
Here is the safest way to do this:
Which generates following code:
json_encode() will ensure that variables are escaped properly and with .apply() method you can pass parameter array to JS function.
Another suggested version:
Generates following: