Uncaught SyntaxError: Unexpected token
Dear all,
I’m facing an issue that seems to be common but I can’t find any solution even after hours of googling.
One of my php script do the following :
- <?php
- $param = array("fld1" => "firstname",
- "fld2" => "lastname");
- ?>
- <button id="edit-btn" onclick="view_lead_make_editable_field(<?php echo json_encode($param) ?>)">Modifier</button>
The javascript function is
- function view_lead_make_editable_field(json_param){
- var obj = JSON.parse(json_param);
- alert(obj.count);
- }
But looking at chrome développer tool, I get the following error : Uncaught SyntaxError: Unexpected token ;
What can I do ?