i want to display 700 products data in a select box and on per selection i have to print a table of description . before i was doing ajax call and showing the data but the process is slow. So i have to send all the data to the client side and then use javascript to change the table of description on option change. Below is my code
<?php
$data = json_encode( get_data_from_db() );
?>
<input type='hidden' name='data' id='data' value= " <?php echo $data; ?>" />
when i do alert in jquery
alert( $("#data").val() );
i only see
{[
value in the alert but when i print the data on the browser it does print in json format ok.
how can i get this data in the javascript and then i have to use loops to extract the data against a specific id and make ul li out of that and then embedd it. please suggest the right approach and whats wrong with the alert. thanks