I have to pass a php json array into a javascript function's on click event.
BEFORE JSON ENCODE PHP ARRAY STRUCTURE:
Array
(
[group_id] => 307378872724184
[cir_id] => 221
)
AFTER JSON ENCODE ARRAY STRUCTURE:
{"group_id":"307378872724184","cir_id":"221"}
The php json array looks like:
if(!empty($cirGrpArr))
$jsonGrpArr = json_encode($cirGrpArr);
I need to pass the same into a javascript on click function like below:
<span onclick="Login(this,JSON.stringify('<?php echo $jsonGrpArr; ?>'))">click here</span>
The php json array is available in this page but how to pass it on click function so that i can iterate this json array to do some other stuff.
$jsonGrpArr
? Don't show us PHP when you have a question about JavaScript. Show us the generated code that is sent to the browser. – Quentin Dec 10 '13 at 12:33