in

Platinum Bay

Peace, Love and Visual Studio Team System

.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).

 

Leave a Comment

(required )  
(optional )
(required )  
Add

About Steve

Steve Andrews has been working as a developer for more than 8 years. During this time, he has designed and developed applications in such widely varying areas as trust accounting, medical information management, supply chain management, and retail systems. He has firsthand developer experience with a variety of languages, including Java, VB, and .NET. Most recently, he has been immersed in SharePoint. He is currently employed at RDA Corporation in Philadelphia, PA, as a Software Engineer and a team member in the Architectural Guidance evangelism team. Steve is also an MTCS (x2), ICSOO, and .NET fanatic.
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.