Menu
Hi guys I am facing problem when passing array as parameter to function. I don’t found any solution that’s why I am here.
Javascript code:
var items = [{“id”:”1″,”name”:”rishi”},{“id”:”2″,”name”:”xyz”}];
var output +=”<button type=’button’ onClick=’print(“+items+”)’>Print</button>”;
$(“body”).append(output);
Html code after run:
<!— it’s coming in function like this [object Object],[object Object] –>
<button type=”button” onClick=’print([object Object],[object Object])’>Print</button>
error in console it’s printing : Uncaught SyntaxError: Unexpected end of input