0

Here's the code I use to ajax more reviews:

function showMoreReviews(str) { var counter = Number($('#counter').val()); var xmlhttp; if (str == "") { document.getElementById("reviews").innerHTML = ""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } counter = counter + 10; $('#counter').attr({ value: counter }); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { //document.getElementById("reviews").innerHTML = xmlhttp.responseText; $("#reviews").append("<div id='rnum" + counter + "'>" + xmlhttp.responseText + "</div>"); $("#rnum" + counter).hide().fadeIn(800); } } console.log(str); console.log(counter); xmlhttp.open("GET", "/MoreReviewsAjax.asp?ml=" + str + "&c=" + counter, true); xmlhttp.send(); } 

It works fine in all browsers except in IE8.. Now here is the weird thing - the code will work if in IE8 I go to dev tools and start debugging for scripts. Otherwise it doesn't work.

PS I am using virtual PC and Windows XP w/ IE8 for IE8 tests.

1 Answer 1

4

Your console.log() calls are the problem.

You can add a cheap "polyfill" to your system:

if (!('console' in window)) { window.console = { log: function() {}, dir: function() {}, // whatever other console functions you use }; } 

Those dummy functions won't do anything, but they'll keep IE from losing it's mind.

Sign up to request clarification or add additional context in comments.

2 Comments

@N0ir When you don't have the developer console open, the console object is not defined and causes an error. (The decision to make it work that way was clearly made by the wrong person.)
I removed console.logs and it works now, thanks. Would have never thought of this... I guess its all about expirience

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.