Click here to Skip to main content
14,927,528 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in php i got this:
PHP
$shipping_part_list_array = $db_obj->getArticleList($elements);


and like this i want to pass it to javascript varriable:
JavaScript
var array = <?php echo  json_encode($shipping_part_list_array); ?>;


but my array variable is just empty. I looked a trought a lot of questions, it seems right but it just wont work. Thank you.
Posted

1 solution

use print() instead of echo
you should use
JavaScript
var array = "<?php print(json_encode($shipping_part_list_array)); ?>";

check it out
Don't forget to use double quotes(")
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900