Output Javascript or Jquery Variables to Firebug Console

Console.log() is a great way to see what your javascript and jquery variables have in them. Debugging made easier. Just add it to the javascript/jquery on the page you want to debug and them check the console in Firebug to see the output. It has been around for a while, but sometimes you just don’t know about these gems.

For example, if you want to see the data that comes back from a jquery post you would do this:

$.post("process_survey.aspx", 
     $("#popup_survey").serialize(), 
     function(data){
          console.log(data);
     }, "json");

The console in Firebug will look like this:
Firebog console 1
And, when you click on “more”, you get this:
Firebog console 2
Firebug has some documentation on console.log for this must-have feature.

Build Internet did a more comprehensive article on Javascript/jQuery console debugging that is a must read.

Posted in jquery, Web development. Tags: . Permalink. Both comments and trackbacks are closed.