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.