title: Call a javascript function with json_encode parameter
body: <p>I would like to call a function onclick, but with a json_encode parameter like this:</p>
  
  <pre><code>&lt;a href="#" onclick="javascript:table1Modif(&lt;?php echo substr(json_encode($res['base']),1,-1); ?&gt;);return false;"&gt;
  </code></pre>
  
  <p>And the Jquery function just alert the parameter:</p>
  
  <pre><code>&lt;script&gt;
      function table1Modif(key){
          $('#table1').html(function() {
              alert(key);
          }); 
  
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>But I have an "undefined" error!
  I am sure that it's due to json_encode, but I don't know how to solve it.
  Thank you!</p>