$.ajax seems to not work in IE. What should I do or it’s just another bug in IE? Do I need to provide my code here to receive help? Because it seems it doesn’t work with any $.ajax example.
My code:
function get_info(lines) {
$.ajax({
type: "POST",
cache: false,
url: "chat.php?RandomNumber=" + Math.random(),
data: "type=get_info&lines="+lines+"&RandomNumber=" + Math.random(),
dataType: "json",
success: function(msg){
lines = msg.lines;
if(msg.new_messages)
{
for(i = 0; i < msg.messages.length; i++)
{
$('.chat').append("<p>"+msg.messages[i]+"</p>");
}
document.getElementById('chatty').scrollTop = document.getElementById('chatty').scrollHeight;
}
},
complete: function() {
setTimeout(get_info, 1000, lines);
}
})
};
setTimeout(get_info, 1000, 0);
I now see that you’re using a form of
setTimeoutthat doesn’t work with IE1, 2:Instead, use an anonymous function as the argument which should call the intended function with the correct argument:
So your initial call to
setTimeoutshould be changed to:and subsequent calls on
successshould be:If this is because IE is caching your GET requests, you could simply set
cachetofalseforjQuery.ajax()and let jQuery handle it for you (remember to clear your cache after making this change):or