javascript - How to put nested php array into java script? -


i have code

        $ref = addslashes(htmlspecialchars(json_encode($value)));         echo '<script>var message_store_'.$key.'=$.parsejson('.$ref.');alert(message_store_'.$key.');</script>';         echo '<div class="message_entry" id ="message_entry'.$key.'" onclick="open_up_thread(\''.$ref.'\',\''.$key.'\');">'.$key.'</div>';         $recent = end($value);         echo '<div id ="recent_message_log_entry'.$key.'"><div>'.$recent['message'].'</div><div>'.$recent['date_posted'].'</div></div>'; 

i facing problem storing array in global javascript variable. have div onclick event working fine array got converted wanted , function open_up_thread parsing encoded json object fine.

i need keep track of array before onclick event fired(after onclick easy converted).

so how achieve storing php array global javascript object json in php.

and reason why have onclick working not variable

thanks in advance

remove $.parsejson() function , remove htmlspecialchars , addslashes:

$ref = json_encode($value); echo '<script>var message_store_'.$key.'='.$ref.';alert(message_store_'.$key.');</script>'; 

json format can directly parsed variable.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -