Google 关闭 IE 中的 XhrIo 问题
以下代码在 IE 中不起作用,在我添加 try
块后,它会警告 Error: Could not Complete the opera due to error c00ce56e.
。
goog.require("goog.dom");
goog.require("goog.net.XhrIo");
goog.require("goog.structs.Map");
goog.require("goog.Uri.QueryData");
var errorMessage = "بروز خطا! بازیابی اخبار در این لحظه امکانپذیر نیست.";
loadPersepolisNews = function() {
var url = 'EsteghlalNews?json=1';
var request = new goog.net.XhrIo();
goog.events.listen(request, "complete", function() {
var container = goog.dom.$("persepolisNewsContainer");
if (container != null && container != undefined) {
if (request.isSuccess()) {
try {
var json = request.getResponseJson();
} catch (e) {
alert(e);
}
for (var i = 0; i < json.length; ++i) {
var news = json[i];
var divNews = goog.dom.createDom('div', {
'class': i % 2 == 0 ? 'news newsEven' : 'news newsOdd'
});
var newsLink = goog.dom.createDom("a", {
'href': news.url,
'target': '_blank',
'class': 'newsLink'
}, news.title);
var newsDate = goog.dom.createDom("span", {
'class': 'newsDate',
'dir': 'ltr'
}, news.persianDate.year + '/' + news.persianDate.month + '/' + news.persianDate.day);
goog.dom.appendChild(divNews, newsLink);
goog.dom.appendChild(divNews, newsDate);
goog.dom.appendChild(container, divNews);
}
} else {
alert(request.getStatusText());
var message = goog.dom.createDom('div', {
'style': 'background-color: red; color: white; padding: 2px'
}, errorMessage);
goog.dom.appendChild(container, message);
console.log(request.getLastErrorCode(), " - message: ", request.getLastError());
}
}
});
request.send(url, "GET");
}
The following code doesn't work in IE, after I added the try
block, it alerts Error: Could not complete the operation due to error c00ce56e.
.
goog.require("goog.dom");
goog.require("goog.net.XhrIo");
goog.require("goog.structs.Map");
goog.require("goog.Uri.QueryData");
var errorMessage = "بروز خطا! بازیابی اخبار در این لحظه امکانپذیر نیست.";
loadPersepolisNews = function() {
var url = 'EsteghlalNews?json=1';
var request = new goog.net.XhrIo();
goog.events.listen(request, "complete", function() {
var container = goog.dom.$("persepolisNewsContainer");
if (container != null && container != undefined) {
if (request.isSuccess()) {
try {
var json = request.getResponseJson();
} catch (e) {
alert(e);
}
for (var i = 0; i < json.length; ++i) {
var news = json[i];
var divNews = goog.dom.createDom('div', {
'class': i % 2 == 0 ? 'news newsEven' : 'news newsOdd'
});
var newsLink = goog.dom.createDom("a", {
'href': news.url,
'target': '_blank',
'class': 'newsLink'
}, news.title);
var newsDate = goog.dom.createDom("span", {
'class': 'newsDate',
'dir': 'ltr'
}, news.persianDate.year + '/' + news.persianDate.month + '/' + news.persianDate.day);
goog.dom.appendChild(divNews, newsLink);
goog.dom.appendChild(divNews, newsDate);
goog.dom.appendChild(container, divNews);
}
} else {
alert(request.getStatusText());
var message = goog.dom.createDom('div', {
'style': 'background-color: red; color: white; padding: 2px'
}, errorMessage);
goog.dom.appendChild(container, message);
console.log(request.getLastErrorCode(), " - message: ", request.getLastError());
}
}
});
request.send(url, "GET");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题出在服务器端(servlet)代码中。
IE 对
charset
值非常敏感。正确的是:
但我是这样写的:(错误)
The problem was in the serverside (servlet) code.
IE is very sensitive to the
charset
value.The correct one is:
But I had written it this way: (wrong)