title: passing an object in javascript function on onclick event
body: <p>I am trying to pass an object to a javascript function which should trigger when a link is clicked. But unfortunately I am not able to get it working.</p>
  
  <p>Here is the code on my jsp file for the same:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          function tryToDoItTwice(obj) {
              var check = obj;
              if(check == null) {
                  return true;
              }
              else {
                  alert("You're not allowed to do this twice!");
                  return false;
              }
          }
      });
  &lt;/script&gt;
  
  &lt;a href="&lt;c:url value="/somepath" /&gt;" onclick="javascript: tryToDoItTwice(${foo});"&gt;Try to do it twice&lt;/a&gt;
  </code></pre>
  
  <p>Here <code>foo</code> refers to an object of type <code>Foo</code>. </p>
  
  <p>Could someone help me understand what am I doing wrong here?</p>
  
  <p><strong>EDIT</strong>: <code>Foo</code> is a java object. and <code>${foo}</code> is a reference variable referring to <code>Foo</code> java object.</p>
  
  <p>Thanks.</p>