Home Ask Login Register

Developers Planet

Your answer is one click away!

JeanBrand February 2016

iOS Firefox XMLHttpRequest wrong response

I have a function that send a XMLHttpRequest GET to retrieve JSON from my backend.

xhttp.onreadystatechange = function()
    if(xhttp.readyState == 4 && xhttp.status == 200)
        if(handler != null)
            if(xhttp.responseText != "" && this.getResponseHeader('content-type') == "application/json")
                handler(JSON.parse(xhttp.responseText), false);
                handler("", true);

xhttp.open("GET", "../../csp/healthshare/hsanalytics/Custom.AMY.REST.Session.cls?CacheUserName="+ username +"&CachePassword="+ password, true);

Now, this function works 100% on any browser on any device, accept iOS Firefox. I have tried going the jQuery route, same results:

      url: "../../csp/healthshare/hsanalytics/Custom.AMY.REST.Session.cls?CacheUserName="+ username +"&CachePassword="+ password,
      cache: false,
      crossDomain: true,
      dataType: "json",
      username: username,
      password: password,
      error: function(event)
          handler("", true);
      success: function(data, status)
          handler(data, false);

I have spent hours researching the topic, but I have not been able to find any articles specific to my problem.


Daniel February 2016

Some browsers are very finicky when it comes to headers.. Have you tried to send basic authorization? Including username and password..


"Authorization": "Basic " + btoa(username + ":" + password)

Give it a go and see :)

Post Status

Asked in February 2016
Viewed 3,836 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life