title: JavaScript variable doesn't work in Laravel
body: <p>All the pages in my website has the same header. I implemented that like this:</p>
  
  <pre><code>extends('layouts.main')
  </code></pre>
  
  <p>Now in some pages, I need to send a successful message and in other pages not. I implemented that like this:</p>
  
  <pre><code>return....-&gt;with(array(
  sucessfulMessage =&gt; 'asdf'
  ));
  </code></pre>
  
  <p>Please note that I do that just in some pages not in all pages.</p>
  
  <p>Now I want to use that variable in JavaScript. I did this in the layout.main:</p>
  
  <pre><code>&lt;head&gt;
      {{ HTML::script('/js/jquery-2.1.1.js')}}
      @if(isset($successfulMessage))
      &lt;script&gt;
          var successfulMessage = "{{$successfulMessage}}";
      &lt;/script&gt;
      @endif
      {{ HTML::script('/js/myPopupScript.js')}}
  &lt;/head&gt;
  </code></pre>
  
  <p>and then in <code>myPopupScript.js</code> I did this:</p>
  
  <pre><code>$(document).ready(function(){
      if(!typeof successfulMessage === 'undefined'){
          alert(successfulMessage);
      }else{
          alert("test");
      }
  });
  </code></pre>
  
  <h3>My problem</h3>
  
  <p>The alert is always <code>test</code> even though when the successfulMessage has been sent.</p>
  
  <h3>Important note</h3>
  
  <p>When I use F12 in Google Chrome to see the actual HTML, I can see this:</p>
  
  <pre><code>&lt;script&gt;
          var successfulMessage = "asdf";
      &lt;/script&gt;
  </code></pre>
  
  <p>so the variable is defined.</p>