0

The following code works perfect in Internet Explorer but in FireFox and Chrome the responseText is empty.

<!DOCTYPE html>
<html>
    <head>
        <title>Untitled</title>
        <script type="text/javascript" language="javascript">
            function UserAction() {
                var httpReq = new XMLHttpRequest();

                httpReq.open("POST", "http://tomcat/security-proxy/reporting-service-v1/reporting-service/api/v1/reporting/rapportelement/155363/16/7?referentie=G.7.0&nocache=false", true);
                httpReq.setRequestHeader("Accept", "application/xml");
                httpReq.setRequestHeader("Content-Type", "application/json");
                httpReq.setRequestHeader("X-Auth-Token", "eyJxxxxxxxxxxxxxxxxxN3iDWV2VMVM8B969YjhP1LiXI");     
                httpReq.send();

                var DateInService = httpReq.responseText;
                alert("Date: " + DateInService);
                document.body.innerHTML += "You work here from: " + DateInService.substring(3, 5) + "/" + DateInService.substring(0, 2) + "/20" + DateInService.substring(6, 8);     
            }
        </script>
    </head>
    <body>
       <button type="submit" onclick="UserAction()">Search</button>
    </body>
</html>

Is there a reason why Internet Explorer shows the correct DateInService and it still be empty in Chrome and FF?

artgb
  • 3,177
  • 6
  • 19
  • 36
Devl_Dirk
  • 1
  • 5
  • And https://stackoverflow.com/questions/20709091/ajax-request-responsetext-is-empty-in-chrome – Huso Nov 06 '17 at 12:26
  • And https://stackoverflow.com/questions/19549269/xhr-responsetext-is-empty-string – Huso Nov 06 '17 at 12:26

0 Answers0