I'm trying to pass a PHP json_encoded object to a function which accepts 2 parameters. But when it's rendered on the browser it kept saying that there's
On Firefox's Inspector:
SyntaxError: missing ) after argument list
On Chrome's Inspector:
Uncaught SyntaxError: Unexpected end of input
Code:
<td>
<a href="#" onclick="showEditModal(<?php echo json_encode($value, JSON_HEX_APOS) ?>)">Edit</a>
</td>
Source Code On Browser:
<td>
<a href="#" onclick="showEditModal({"id":2,"title":"Announcement 1","content":"Announcement 1 Content","dateAdded":"2018-04-24 14:44:27"})">Edit</a>
</td>
I tried adding \'' but didn't help. Maybe I'm doing it wrong. I've been on this since last night so I think I need to ask now.
I clear the browser's cache everytime I test but I get the same result. There are similar questions but I tried them but won't fix my problem.
I'd appreciate any help.
"to'for the onclick function.