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 -.-@!#