Safari xhr (AJAX) requests w/ cross-domain redirect fails
Asked Answered
V

1

7

How to reproduce the issue

  1. Make an AJAX request to a server using Safari
  2. Have the server response w/ 302 to a different domain

If either of those conditions is not met, it works.

  1. Use a different browser, it works.
  2. Have the server redirect to same domain, it works.

.

Load: function (in_url, in_cb, in_responseType) {
  var xhr = new XMLHttpRequest();
  xhr.open('GET', in_url, true);
  xhr.onload = function () {
    if (xhr.status === 200) {
      in_cb(null, xhr.response);
    } else {
      in_cb(new Error('[Loader] Could not fetch from: '+in_url+', status: '+xhr.status));
    }
  };
  xhr.onerror = function (error) {
    in_cb(error);
  };

  xhr.send();
}

enter image description here enter image description here

Voice answered 9/10, 2015 at 17:47 Comment(2)
This is a known issue with Safari. It seems like it's actually being worked on as of recently bugs.webkit.org/show_bug.cgi?id=112471.Doerr
Nevertheless make sure your server supports CORSEma
K
1

This bug was fixed.
Safari 10.1 (WebKit 603.1.30) was the first version not affected.

Khabarovsk answered 18/2, 2018 at 4:49 Comment(1)
Thank you! Unfortunately I asked so long ago I no longer have the code lying around to test. If someone can confirm that it's fixed I will mark your response as correctVoice

© 2022 - 2024 — McMap. All rights reserved.