title: Cant retrieve an XML list from a web service
body: <p>I have a server running OTRS 5 and I would like to retrieve a list in XML format. I'm running a JavaScript code that should display the list, but instead I get an error.</p>
  
  <p>My local server is <code>https://labcentos3/otrs/mds.pl?Action=ServiceList</code>.</p>
  
  <p>I think its a Perl script that runs on the server side and then displays a list in XML format.</p>
  
  <p>This is what I get if I browse the local link: it gives me the list I want</p>
  
  <p><img src="https://i.stack.imgur.com/aXFUH.jpg" alt="This is what I get if I browse the local link, it gives me the list I want"></p>
  
  <p>I wrote HTML and JavaScript to try to do the same for working with the retrieved data later, but I can't get past an error.</p>
  
  <h3>HTML</h3>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;XML read&lt;/title&gt;
          &lt;script src="reader.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;XML File&lt;/h1&gt;&lt;br/&gt;
      &lt;/body&gt;
  &lt;/html&gt;       
  </code></pre>
  
  <h3>reader.js</h3>
  
  <pre class="lang-js prettyprint-override"><code>var user = "bla bla bla";
  var pass = "bla bla bla"
  
  var getXMLFile = function(path, callback) {
      var request = new XMLHttpRequest();
      request.open("POST", path);
      request.setRequestHeader("Content-Type", "text/plain");
      //request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      request.setRequestHeader('Authorization', 'Basic ' + btoa(user + ":" + pass));
      request.onreadystatechange = function() {
          if(request.readyState === 4 &amp;&amp; request.status === 200) {
              callback(request.responseXML);
          }    
      };
      request.send();
  };
  
  getXMLFile("https://labcentos3/otrs/mds.pl?Action=ServiceList", function(xml) {
     console.log(xml); 
  });
  </code></pre>
  
  <p>The error I get in the Chrome console is this:</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="https://labcentos3/otrs/mds.pl?Action=ServiceList" rel="nofollow noreferrer">https://labcentos3/otrs/mds.pl?Action=ServiceList</a>. The request was redirected to '<a href="https://labcentos3/otrs/index.pl" rel="nofollow noreferrer">https://labcentos3/otrs/index.pl</a>', which is disallowed for cross-origin requests that require preflight.</p>
  </blockquote>