user3056105
user3056105

Reputation:

console.log() not working in visual studio 2012

I am trying log json data onto console using following code and I want to debug it using developers tool provided by IE.

My Code is

$.getJSON("s13.aspx", function (data3, textStatus3) {
                     console.log(textStatus3);}

But I am having error that console is undefined.

Why is it happening? How to solve it?

Upvotes: 2

Views: 2797

Answers (2)

gaurav5430
gaurav5430

Reputation: 13917

console doesn't exist in IE unless the console is actually open

check this link for a detailed discussion:

Internet Explorer: "console is not defined" Error

to check whether console is defined or not, you can do

if ('console' in window)

Upvotes: 1

E. S.
E. S.

Reputation: 2919

Use if(window.console) first.

if( window.console ){
   console.log('hi');
}else{
   alert('console not avaliable');
}

https://developer.mozilla.org/en-US/docs/Web/API/console

Upvotes: 2

Related Questions