IE 中的 Ajax 问题
这段代码在 FireFox 上工作正常,但在 IE 中,当我尝试转储 AJAX 响应返回的响应内容时,它会给出运行时错误。我正在使用 mootools 进行 Ajax 调用。
//on dom ready...
window.addEvent('domready', function() {
/* ajax alert */ <br/>
$('ajax-alert').addEvent('click', function(event) {
//prevent the page from changing
event.stop();
//make the ajax call
var req = new Request({
method: 'get',
url: $('ajax-alert').get('href'),
data: { 'do' : '1' },
onRequest: function() { alert('Request made. Please wait...'); },
onComplete: function(response) {
alert(response);// Getting response and able to see that in alert
/*line underneath fives runtime error in IE , works fine in FireFox */
document.getElementById('myDiv').innerHTML = response;
//this line gives run time error on IE
}
}).send();
});
This chunk of code works fine on FireFox but in IE it gives runtime error when I try to dump the contents from response returned from AJAX response.I am using mootools to make Ajax call.
//on dom ready...
window.addEvent('domready', function() {
/* ajax alert */ <br/>
$('ajax-alert').addEvent('click', function(event) {
//prevent the page from changing
event.stop();
//make the ajax call
var req = new Request({
method: 'get',
url: $('ajax-alert').get('href'),
data: { 'do' : '1' },
onRequest: function() { alert('Request made. Please wait...'); },
onComplete: function(response) {
alert(response);// Getting response and able to see that in alert
/*line underneath fives runtime error in IE , works fine in FireFox */
document.getElementById('myDiv').innerHTML = response;
//this line gives run time error on IE
}
}).send();
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当返回的响应不是有效的 X/HTML 时,可能会发生这种情况。我建议您使用返回的响应来验证页面。正如 Dimitar Christoff 提到的,请注意包含块元素的内联元素。
This is likely to happen when the returned response is not a valid X/HTML. I suggest you validate the page with the response returned in it. As Dimitar Christoff has mentioned, watch out for inline elements containing block elements.