4

The jQuery $.post() function is not working in IE. I tried to open developer tools to see if I was getting a console error, but miraculously the function started working.

It is just a standard $.post() function

$.post('child_cb.php?type=check', { value: $(this).val() }, function(data) {
                        console.log(data);
                        if (data == 'true') {
                            $(".check_case").removeClass('bad').addClass('good');
                        }
                        else if (data == 'false') {
                            $(".check_case").removeClass('good').addClass('bad');
                        }
                    });

I see no reason why it wouldn't work.

watzon
  • 2,401
  • 2
  • 33
  • 65
  • 1
    are you sure it is not working without developer tools? I wouldn't really trust anything IE. If you want to verify AJAX calls it is best to stick with Fiddler. It will show you what is really going on. – Ilia G Oct 22 '11 at 20:14
  • Well, what's the error/symptom(s)? -1 for "it's not working". –  Oct 22 '11 at 20:15
  • And why the down votes? Seriously... – watzon Oct 22 '11 at 20:44
  • To down voter: really!?!? it is as good a question as any, and asked as well as it can be if you don't know what is going on with the logger. – webLacky3rdClass Jan 31 '12 at 16:47
  • This totally fixed my issue. +1 – CodeLikeBeaker Feb 17 '12 at 22:03
  • Possible duplicate of [Why does JavaScript only work after opening developer tools in IE once?](http://stackoverflow.com/questions/7742781/why-does-javascript-only-work-after-opening-developer-tools-in-ie-once) – 1615903 May 10 '17 at 12:20

2 Answers2

23

remove/comment out the console.log(data), IE cannot process this, it should work fine after you remove this. Had this problem myself recently.

Anil
  • 21,730
  • 9
  • 73
  • 100
1

You should make a habit of using this for debugging so you don't forget the console.log :

if(!('console' in window) || ( ('console' in window) && !('log' in console) )){  
    window.console = {  
        log:function(e){  
            alert("You are using console log without the console!")  
        }  
    }  
}

you can remove the alert, but is ok if you want to be notified that you forgot something. :)

webLacky3rdClass
  • 659
  • 10
  • 27
cuzzea
  • 1,515
  • 11
  • 22