in

Platinum Bay

Peace, Love, and...

This Blog

Syndication


.NETicated

Visual Studio 2008 JavaScript Debugging

Tonight, or this morning as the case may be, I was running into an issue with jQuery and the getJSON method. Basically, I was calling the method, with the proper parameters, but nothing was happening. The server method wasn't being called, and JavaScript debugging alerts weren't being fired either. After fiddling with the JavaScript for awhile, I decided to check out the JavaScript debugging feature which was added to Visual Studio 2008.

Since I'd never used it before, I did the most logical thing I could think of, I searched. It turns out that JavaScript debugging is very easy to setup.

First, go into your browser and enable script debugging. For Internet Explorer 7, go to Tools | Options | Advanced, and uncheck 'Disable script debugging (Internet Explorer)' and 'Disable script debugging (Other)'. For Firefox, JavaScript debugging appears to be enabled by default.

Next, in Visual Studio, type Ctrl+Alt+P to open the 'Attach to Process...' dialog, and select either firefox.exe or iexplore.exe depending on which browser you are using.

Finally, set breakpoints in your JavaScript code, and perform the action in the browser to get to the breakpoints. After that, you can use the standard Step Into and Step Over to navigate through your JavaScript. Visual Studio also provides debugger tooltips to explore your JavaScript objects, which is what ultimately led me to the response of the XmlHttpRequest object, and the realization that I had mis-named a server method parameter.

With the popularity of jQuery, and other JavaScript libraries, I foresee this feature being widely used among web developers.

Comments

November 1, 2008 6:40 AM

If you're willing to not debug in VS, you can also use FireBug inside of Firefox to let you set breakpoints straight inside your browser to stay within the same environment and save window switching (very useful for those of us on single monitor rigs/laptops).

 

May 25, 2010 3:00 PM

Thank you Steve,

It would be helpful to all developers whoever using this technologies,

Rakesh
 

February 25, 2011 3:45 AM

Good one, this one made my day ;-)

Shotemba
 

June 1, 2011 2:01 PM

I am trying to debug Firefox 4 in Visual Studio 2008. I am not able to put the break point in Java Script code. It would be nice if you suggest me where I should go and enable the JavaScript debugging setting in Firefox.

For my case, I belive Visual Studio 2008 is not able to execute the page in firefox in debug mode.

Ajit
 

Leave a Comment

(required )  
(optional )
(required )  
Add

About Steve

Steve Andrews is an independent consultant, INETA speaker, and Microsoft MVP for Visual Studio ALM. He has been working in technology for over ten years focusing on custom application development and Application Lifecycle Management. Steve is also Microsoft and IBM certified and a community fanatic having led sessions at nearly 100 events across North America. When he's not developing software solutions or engaging with the community about software technology, Steve is a closet singer and songwriter and plays the guitar and keys. Occasionally, Steve even gets to sleep. Occasionally.
Powered by Community Server (Commercial Edition), by Telligent Systems
© Platinum Bay | Some Rights Reserved Creative Commons License

Disclaimer: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Feel free to challenge me, disagree with me, or tell me I'm completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or annonymous comments) - so keep it polite, please.