Can I use Visual Studio 2010 to debug javascript and let me stop and watch variables?
I'm using VS2010. I have javascript visible and I placed a breakpoint in a function like below:
funct开发者_StackOverflowion doShow() {
// $('#save').click(function () {
var product = { ProductName: $('!Response[0]').val(),
UnitPrice: $('#Price').val(),
alert(product);
I placed a breakpoint on the line starting with var and the line starting with Alert. VS2010 accepted the breakpoint and put a small red circle with white center there.
When I run the script the alert shows but it never stops at the breakpoint.
Any ideas what I am doing wrong. note my code is running local
Install the Firebug add-on for Firefox. It will allow you to do all kinds of Javascript (and other) debugging, inside the browser.
A technique you can use to debug JavaScript using Visual Studio is to add this code to your JavaScript and then run your page in IE.
debugger;
The best way that I've found to debug JavaScript is to use the built in developer tools found in IE9 and Chrome (or Firebug in Firefox as mentioned in this discussion). Since JavaScript is a client-side language, I'm not sure that Visual Studio will have access.
Resources on using JavaScript Debuggers:
- Using Firebug
- Discussion on using the Chrome Debugger
Edit: As indicated below, you can use Visual Studio with IE.
精彩评论