I am generating an `onclick` handler dynamically and setting it using the `attr` method.

```
var originReference = "myDynamicString";
var stringArray = [];
stringArray.push("Data1");
stringArray.push("Data2");
var objArray = [];
objArray.push({name: "Category 1", y: 10});
objArray.push({name: "Category 2", y: 20});

onclickReference.attr("onclick", "drawChart('" + originReference + "',[" + stringArray + "],[" + objArray + "]); return false;");

```

With this code, the `objArray` is not being passed properly to the handler event as I am getting the error:

> 
> "SyntaxError: missing ] after element list".
> 
> 
> 

Using just an array of strings (no JSON). The data is passed to the handler just fine.

How can I format my object array in the `onclick` handler?