I have a php array that is being passed to a js function using "json_encode($array)", the problem is that when I click the button to trigger the function, nothing happens besides the page refreshing.
I think the problem might be the enclosing quotes, though I already tried changing from double to single and vice verse, no joy.
HTML:
<button class="button1"
onclick="validateEncomenda('<?php echo json_encode($chosen_restaurant_addr);?>');
return false;">Encomendar</button>
js:
function validateEncomenda(myarray){
alert('Hello JS');
}
if I echo the "json_encode($chosen_restaurant_addr)" I'm getting the right values in this format:
["ipsum lorem blah blah","Curabitur aliquam feugiat tellus"]
Any help or hint will be greatly appreciated.