title: AJAX error "setRequestHeader" is not defined
body: <p>I am a little confused on what I am doing wrong in my code </p>
  
  <pre><code>function submitArticle() { 
     var postTitle = encodeURIComponent(document.getElementById('postTitle').value);
     var postDes   = encodeURIComponent(document.getElementById('postDes').value);
     var postCont  = encodeURIComponent(document.getElementById('postCont').value);   
     var data = "postTitle=" + postTitle + "&amp;postDes=" + postDes + "&amp;postCont=" + postDes;                                     
     var getXML =  function () {
          try {
  
              xhr = new XMLHttpRequest();
            }
            catch(e) {
              try {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
              }
              catch(e) {
                try {
                    xhr = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch(e) {
                  alert("Your Browser is not Supported");
  
                }
              }                          
            }                                
        } 
         open('POST', 'http://localhost/blog/engine/engine.php', true);
         setRequestHeader("Content-type", "application/x-www-form-urlencoded");               
         send(data);                                                                                                              
         getXML.onreadystatechange = function() {
            if(this.readyState === 4) {
                if(this.status ===200) {
                   alert(this.responseText);
                }
                else {
                  alert("status" + this.status);
                 }
            }
            else {
              alert("readyState" + this.readyState);
            }
        }
     getXML();                                                                                           
     return true;               
  }
  </code></pre>
  
  <p>I am using an onclick event for this. I have checked the URL and made sure that I did not make any mistakes in entering the values of the variables.  I am getting "setRequestHeader is not defined" error  along with a new windows that shows the link "localhost/blog/app/POST" </p>
  
  <p>I have looked up as much as I could and I am not sure what to do next.<br>
  Also. there must be a better way to write the code than what i did for getXML() function. </p>