title: how to disable submit button with ajax based on ajax response
body: <p>I am trying to use something like this in my code but having no luck...</p>
  
  <pre><code>function captcha(data) {
      var httpxml;
      try {
          // Firefox, Opera 8.0+, Safari
          httpxml = new XMLHttpRequest();
      }
      catch (e) {
          // Internet Explorer
          try {
              httpxml = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e) {
              try {
                  httpxml = new ActiveXObject("Microsoft.XMLHTTP");
              }
              catch (e) {
                  alert("Your browser does not support AJAX!");
                  return false;
              }
          }
      }
  
      function stateck() {
          if (httpxml.readyState == 4) {
              document.getElementById("cap_error").innerHTML = httpxml.responseText;
              var result = httpxml.responseText;
              if (result == 'Error..try again') {
                  document.getElementById("regSubmit").disabled = true;
              }
  
  
          }
      }
      var url = "includes/captcha.php";
      url = url + "?datacap=" + data;
      url = url + "&amp;sid=" + Math.random();
      httpxml.onreadystatechange = stateck;
      httpxml.open("GET", url, true);
      httpxml.send(null);
  }
  </code></pre>
  
  <p>Edit:</p>
  
  <p>My submit button is:</p>
  
  <pre><code>&lt;input type="submit"  value="Submit" id="regSubmit" name="Submit"/&gt;  
  </code></pre>
  
  <p>When ajax function returns 'Error..try again' regSubmit button should be disabled. But this function is not working for my right now.</p>
  
  <pre><code>if (result == 'Error..try again')
  {
    document.getElementById("regSubmit").disabled = true;
  }
  </code></pre>