jquery ajax兼容IE8,jquery ajax ie8

i have a problem with ajax and ie8.

my script:

$('#buton').click(function () {

$('#reader-cont #imgw, #reader-cont #txtw, #reader-cont #datew, #reader-cont #sharemew').html('

$('#reader').stop().fadeTo(1000, 1).css('z-index', 100);

var link = $(this).attr('href');

$.ajax({

url: link,

cache:false,

success: function(data) {

var imgW = $(data).find("#content #img");

var txtW = $(data).find(".cont-cont").text();

var dateW = $(data).find("#content #date");

var shareW = $(data).find('#content #shareme')

$("#reader-cont #imgw").html(imgW);

$("#reader-cont #txtw").html(txtW);

$("#reader-cont #datew").html(dateW);

$("#reader-cont #sharemew").html(shareW);

alert(txtW);

}

});

});

ff and chrome don't have a problem to load a content, but ie8 don't load nothing... why??? i know ie8 have a problem with a cahe, for it i write cache:false,,but not load.........

more info:

the alert(txtW); return empty string...

if i remove .text() from var txtW = $(data).find(".cont-cont").text(); return in alert windows "Object, Object"...

update: i switch the script with this:

loadXMLDoc();

function loadXMLDoc()

{

var xmlhttp;

if (window.XMLHttpRequest)

{// code for IE7+, Firefox, Chrome, Opera, Safari

xmlhttp=new XMLHttpRequest();

}

else

{// code for IE6, IE5

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

xmlhttp.onreadystatechange=function()

{

if (xmlhttp.readyState==4 && xmlhttp.status==200)

{

var data= xmlhttp.responseText;

alert(data);

var imgW = $(data).find("#content #img");

var txtW = $(data).find(".cont-cont");

var dateW = $(data).find("#content #date");

var shareW = $(data).find('#content #shareme')

$("#reader-cont #imgw").html(imgW);

$("#reader-cont #txtw").html(txtW);

$("#reader-cont #datew").html(dateW);

$("#reader-cont #sharemew").html(shareW);

}

}

xmlhttp.open("GET",link,true);

xmlhttp.send();

}

the alert in ie8 run perfectly, but in the div i don't see nothing.... the cache is not a problem now... the problem is find the selector in loaded content...

i tested it in ie9 ff chrome safari... work perfectly...

but not in ie8

update 2:

i learn the problem is .find, because the alert return the page for data.

i try in this method, but ie8 don't run :(

i switch this line:

var imgW = $(data).find("#content #img");

var txtW = $(data).find(".cont-cont");

var dateW = $(data).find("#content #date");

var shareW = $(data).find('#content #shareme')

with this line:

var data= xmlhttp.responseText;

var imgW = $(data).children('#wrapper').children('#content').children(' .region').children('#block-system-main').children('.content').children('#img');

var txtW = $(data).children('#wrapper').children('#content').children(' .region').children('#block-system-main').children('.content').children(".cont-cont");

var dateW = $(data).children('#wrapper').children('#content').children(' .region').children('#block-system-main').children('.content').children("#content #date");

var shareW = $(data).children('#wrapper').children('#content').children(' .region').children('#block-system-main').children('.content').children('#content #shareme');

ff chrome no prob ie8 don't run -.-@!#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值