Use data from view in javascript <p>I was wondering if it's possible to use data from the view in my javascript code? This is what I have:</p> <p>View "<strong>index.phtml</strong>":</p> <pre><code>&lt;?php $event = $this-&gt;event; ?&gt; &lt;script&gt; // HERE I WANT TO USE $event var data = &lt;?=$event?&gt;; &lt;/script&gt; </code></pre> <p>But that doesn't work!</p>