title: Unique Id without submission of form in ajax php
body: <p>I have a form there are 5 fields where I want to automatic generate roll number in 5th field after filling up 4 fields(Name,Phone,Course,Batch) without submitting form.but after filling up 4 field no value comes in 5th field(roll).Below is my code</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &lt;head&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;script&gt;
      function my_validate_func() {
          if ($('#name').val() != "" &amp;&amp; $('#phone').val() != "" &amp;&amp;
              $('#course').val() != "" &amp;&amp; $('#center').val() != "") {
              $.ajax({
                  type: "POST",
                  url: 'submit.php',
                  success: function(response) {
                      $('#roll').val(response.roll);
                  }
              });
          }
      }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;form method="post" action=""&gt;
          &lt;input type="text" name="name" id="name" onchange="my_validate_func()"&gt;
          &lt;input type="text" name="phone" id="phone" onchange="my_validate_func()"&gt;
          &lt;input type="text" name="course" id="course" onchange="my_validate_func()"&gt;
          &lt;input type="text" name="center" id="center" onchange="my_validate_func()"&gt;
          &lt;input type="text" name="roll" id="roll" value="&lt;?php $roll; ?&gt;"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  
  **submit.php code is below**
  
  &lt;?php
  $roll=rand(100000,999999);
  echo $roll;
  ?&gt;
  </code></pre>