I have this PHP code
echo '<a href='#' onclick='updateByQuery(\'Layer3\', ' . json_encode($query) . ');'>Link 1</a>';
which generates a link like this:
<a href='#' onclick='updateByQuery('Layer3', 'Ed Hardy');'>Link 1</a><li>Link 2</li>
Causing the javascript to not be called. How would I make it generate single quotes around the result of $query, in this case ed hardy?
Try to do the reverse… use single quotes for html, and double quotes for javascript. That’s how we do that in fact.