[英]FETCH IE11: second fetch is not working in ie 11
the first time fetch is called, everything works correctly.第一次调用 fetch 时,一切正常。 on the second call, I get false.
在第二个电话中,我得到了错误。 It works correctly in Chrome.
它在 Chrome 中正常工作。 Polyfill fetch is connected.
Polyfill fetch 已连接。
The code below translates to ES5 before uploading it to the server.下面的代码在将其上传到服务器之前转换为 ES5。 I have hidden some variables.
我隐藏了一些变量。
const url = `Fake url for example`; function addData(data) { console.log("Affiche", data); const randomAffiche = data.data[getRandomInt(data.data)]; const date = randomAffiche.PROPERTY_DATES_VALUE.split('-')[1]; eventImgElem.src = randomAffiche.IMG; eventTitleElem.innerHTML = randomAffiche.NAME; eventTitleElem.href = randomAffiche.DETAIL_PAGE_URL; eventLink.href = randomAffiche.DETAIL_PAGE_URL; eventDate.innerHTML = getMonth(date); eventLink.innerHTML = randomAffiche.PROPERTY_VENUE_VALUE; whereToGoLink.href = '/kudago/'; } function fetchData(city) { try { fetch(url + city) // This fetch is returned data = false. Why? .then(data => { data.json() .then(data => { console.log("fetchData", data); addData(data); }) }) } catch (e) { console.log(e); } } function getCity() { const url = "fake url for example"; try { fetch(url) // This fetch is good .then(data => { data.json() .then(data => { console.log("getCity", data) if (data.data) { fetchData(data.data.name); } else { console.log("Error getCity", data); } }) }) } catch (e) { console.log(e); } } getCity();
This method helped me https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent这种方法帮助了我https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
encodeURIComponent(url)
IE 11 did not understand the cyrillic alphabet. IE 11 无法理解西里尔字母。 this will help those who have Cyrillic in the request.
这将帮助那些在请求中包含西里尔文的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.