title: Uncaught TypeError: Cannot set property 'display' of undefined
body: <p>I am in the process of migrating an existing platform to a new server.  I am taking the opportunity to upgrade PHP ect and standardise/debug the code as the previous maintainers have had different standards.</p>
  
  <p>I have opted for PHP version 5.4.33 for now, once I have managed to move everything over to mysqli I will look to go to a more recent version.  I didnt think anything server side would make a difference to AJAX/JS?  As far as I am aware is it not client side?</p>
  
  <p>Since I have moved the code over I am having issues with AJAX/JS.  I am not the greatest at AJAX/JS and could use some assistance please.  Even though every submit works differently through the entire platform I do not want to remove the AJAX/JS that already exists.  I will most likely use it as an opportunity to how to use it as it makes end user experience smoother.</p>
  
  <p>Using Chrome to debug I am receiving the following error on clicking the Save button:</p>
  
  <pre><code>Uncaught TypeError: Cannot set property 'display' of undefined
  email_user
  onclick
  </code></pre>
  
  <p>This is the Save button code</p>
  
  <pre><code>&lt;span id="loading" style="color: red; font-size: x-small; display: none; text-decoration: blink;"&gt;Loading... Please wait..&lt;/span&gt;&lt;input type="button" value="Save" class="save" onclick="if(validate()){ email_user(); }" /&gt;
  </code></pre>
  
  <p>This is the function code for validate()</p>
  
  <pre><code>function validate() {
  
      var errorString = "";
  
      if(isBlank(document.getElementById("forename").value)) {
          errorString += " - Please input a forename\n";
      }
      if(isBlank(document.getElementById("surname").value)) {
          errorString += " - Please input a surname\n";
      }
      if(isBlank(document.getElementById("company_name").value)) {
          errorString += " - Please select a company\n";
      }
  
      if(document.getElementById("username").value != "" || document.getElementById("password").value != "") {
          if(isBlank(document.getElementById("username").value)) {
              errorString += " - Please input a username\n";
          }
          if(isBlank(document.getElementById("password").value)) {
              errorString += " - Please select a password\n";
          }
      }
  
      //if not a solicitor then cases mandatory
      if(document.getElementById("company_role_type_id").value == 2) { 
          if(document.getElementById("other_view_if").value == "") {
              errorString += " - Please select who can view your cases\n";
          }
      }
      if(document.getElementById("company_role_type_id").value == 3) { 
          if(document.getElementById("other_view_ea").value == "") {
              errorString += " - Please select who can view your cases\n";
          }
      }
  
      if(errorString) {
          alert('Please correct the following items:-\n\n'+ errorString);
          return false;
      }
      else {
  
          return true;
      }
  }
  </code></pre>
  
  <p>This is the function code for email_user()</p>
  
  <pre><code>function email_user(){
  
  if(skip_email == true){ $('user').submit(); }
  
  var url  = 'email_user.php';
  var params = '?' + $('user').serialize() + '&amp;from_edit=1';
  
  $('loading').style.display = 'inline';
  
  var myAjax = new Ajax.Request(
                      url,
                      {
                              method: 'get',
                              parameters: params,
                              onComplete: show_response
                      });
  
  function show_response(this_request){
  
  //alert(this_request.responseText);
  
      var reply = this_request.responseText.evalJSON(true);
  
      if(reply['status'] == false){ var blah = ''; }
  
      else{ alert(reply['message']); }
  
  //$('loading').style.display = 'none';
  
      $('user').submit();
  
      }
  
  }
  </code></pre>
  
  <p>Thinking about it, maybe it is more to do with the Apache version??  Just in case Apache version is 2.2.15.</p>
  
  <p>Any assistance you guys can give me will be greatly appreciated!  If you need any more information please let me know.</p>
  
  <p>Kind Regards,</p>
  
  <p>n00bstacker</p>