title: Can't get javascriptRoutes to work with Play Framework 2
body: <p>I'm trying to use <code>javascriptRoutes</code> in Play 2 (Scala) and I am getting an error (see below). Here is what I did:</p>
  
  <h3>Add <code>javascriptRoutes</code> method to <code>Application</code> controller</h3>
  
  <pre><code>def javascriptRoutes = Action { implicit request =&gt;
      import routes.javascript._
      Ok(Routes.javascriptRouter("jsRoutes")(Orders.searchProducts))
          .as("text/javascript")
  }
  </code></pre>
  
  <h3>Add route to <code>routes</code> file</h3>
  
  <pre><code>GET    /assets/javascripts/routes    controllers.Application.javascriptRoutes
  </code></pre>
  
  <h3>Add <code>&lt;script&gt;</code> import to <code>main.scala.html</code></h3>
  
  <pre><code>&lt;head&gt;
  ...
  &lt;script type="text/javascript" src="@routes.Application.javascriptRoutes"&gt;&lt;/script&gt;
  ...
  &lt;/head&gt;
  </code></pre>
  
  <p>With these changes in place I am getting the following error in the JavaScript console:</p>
  
  <pre><code>GET http://localhost:9000/assets/javascripts/routes 404 (Not Found)
  Uncaught ReferenceError: jsRoutes is not defined
  </code></pre>
  
  <p>What am I missing?</p>