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

那年仲夏 提交于 2020-01-02 02:55:09

问题


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();
}


回答1:


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



来源:https://stackoverflow.com/questions/33044293/safari-xhr-ajax-requests-w-cross-domain-redirect-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!