title: Using Jquery AJAX function with datatype HTML
body: <p>We have a complete code for getting the values from PHP through Jquery AJAX with JSON datatype. Here are the codes. </p>
  
  <p><strong>HTML CODE</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
      &lt;title&gt;Ajax submit&lt;/title&gt;
      &lt;link href="css/main.css" type="text/css" media="screen, projection"rel="stylesheet" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id="wrapper"&gt;
          &lt;div id="message" style="display: none;"&gt;
          &lt;/div&gt;
          &lt;div id="waiting" style="display: none;"&gt;
              Please wait&lt;br /&gt;
              &lt;img src="images/ajax-loader.gif" title="Loader" alt="Loader" /&gt;
          &lt;/div&gt;
          &lt;form action="" id="demoForm" method="post"&gt;
              &lt;fieldset&gt;
                  &lt;legend&gt;Demo form&lt;/legend&gt;
                  &lt;span style="font-size: 0.9em;"&gt;TEST by ROD&lt;/span&gt;
                  &lt;p&gt;
                      &lt;label for="email"&gt;E-Mail:&lt;/label&gt;
                      &lt;input type="text" name="email" id="email" value="" /&gt;
                  &lt;/p&gt;
                  &lt;p&gt;
                      &lt;input type="submit" name="submit" id="submit" style="float: right; clear: both; margin-right: 3px;" value="Submit" /&gt;
                  &lt;/p&gt;
              &lt;/fieldset&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      &lt;script type="text/javascript" src="js/jquery/jquery-1.3.2.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="js/ajaxSubmit.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>PHP CODE</strong></p>
  
  <pre><code>sleep(3);
  
  if (empty($_POST['email'])) {
      $return['error'] = true;
      $return['msg'] = 'You did not enter you email.';
  }
  else {
      $return['error'] = false;
      $return['msg'] = 'You\'ve entered: ' . $_POST['email'] . '.';
  }
  
  echo json_encode($return);
  </code></pre>
  
  <p><strong>JS CODE</strong></p>
  
  <pre><code>$(document).ready(function(){
  $('#submit').click(function() {
  
      $('#waiting').show(500);
      $('#demoForm').hide(0);
      $('#message').hide(0);
  
      $.ajax({
          type : 'POST',
          url : 'post.php',
          dataType : 'json',
          data: {
              email : $('#email').val()
          },
          success : function(data){
              $('#waiting').hide(500);
              $('#message').removeClass().addClass((data.error === true) ? 'error' : 'success')
                  .text(data.msg).show(500);
              if (data.error === true)
                  $('#demoForm').show(500);
          },
          error : function(XMLHttpRequest, textStatus, errorThrown) {
              $('#waiting').hide(500);
              $('#message').removeClass().addClass('error')
                  .text('There was an error.').show(500);
              $('#demoForm').show(500);
          }
      });
  
      return false;
  });
    });
  </code></pre>
  
  <p>I just want to Move this code to HTML format, actually above these codes are made by internet user. due to my limited knowledge in AJAX/JS . we are unable to make it AJAX with HTML datatype. </p>
  
  <p>The whole programme is good and according to our need. At the moment we just want to DISABLE the JSON and ENABLE HTML DATATYPE.</p>