title: Getting error when passing object in onclick event
body: <p>Getting error when passing object in onclick event <a href="https://jsfiddle.net/fddr0bnv/9/" rel="nofollow">fiddle</a></p>
  
  <pre><code>(function() {
    function a() {
      var x = [{
        "name": "main",
        "data": {"name":'john'}
      }, {
        "name": "sub",
        "data": {"name":'guru'}
      }, {
        "name": "lower",
        "data": {"name":'jack'}
      }]
      for (var i = 0; i &lt; x.length; i++) {
        var data = "&lt;span onclick='getInfo(" + x[i].data + ")'&gt;main &lt;/span&gt;";
        data += "&lt;span onclick='getInfo(" + x[i].data + ")'&gt;sub &lt;/span&gt;"
        data += "&lt;span onclick='getInfo(" + x[i].data + ")'&gt;lower&lt;/span&gt;&lt;br&gt;"
        $('#data').prepend(data);
      }
    }
    a()
  })()
  </code></pre>