title: Loading templates with ajax in Play Framework
body: <p>I am trying to load a template (html file) using an ajax driven html link. so i have a navigation bar on the left and each html anchor invokes a jquery ajax request to load a template in the right hand side div. </p>
  
  <p>The page loads, it's a form, but when trying to validate the form it fails. </p>
  
  <p>Are there any restrictions to loading html templates using ajax? If i load the page through a standard route definition (http://localhost:9000/signup) it loads and validates the form. </p>
  
  <p>ajax code is something like:</p>
  
  <pre><code>    $.ajax({
        url: '/signup',
        type: 'GET',
        dataType: 'html',
        success: function(data){
          $('#signup).html(data);
        }             
      }); 
  </code></pre>
  
  <p>All /signup does is render the page:</p>
  
  <pre><code>    public static signup(){
        render();
      }
  </code></pre>
  
  <p>and the html template is:</p>
  
  <pre><code>    #{extends 'main.html' /}
      #{set title:'test the validation' /}
  
      #{jQueryValidate class:models.User.class, key:'user' /}
      &lt;div&gt;
  &lt;p&gt;Candidate...&lt;/p&gt;
  
  &lt;form method="POST" id="joinForm"&gt;
      &lt;p class="field"&gt;
          &lt;span class="error"&gt;#{error 'user.firstname' /}&lt;/span&gt;                     &lt;label&gt;Mobile&lt;/label&gt;
          &lt;input type="text" name="user.firstname"
              value="${flash['user.firstname']}" /&gt;
      &lt;/p&gt;
  
      &lt;input type="submit" name="create" value="Register" /&gt;
  </code></pre>
  
  <p><br>
  </p>
  
  <p>and the form is submitted using:</p>
  
  <pre><code>    $('#joinForm').submit(function(e) {     
  $.ajax({
   type: "POST",
   url: '@{candidate.index()}',
   beforeSend: doValidation,
   success: function() {
       $('#success').html("created...");
   }
   });
   e.preventDefault(); 
      }); 
  </code></pre>
  
  <p>the doValidation is the form validation (code taken from samples-and-tests/validation/Sample 7)</p>
  
  <p>Appreciate any insight to solving this, before having to change my design</p>
  
  <p>thanks</p>