最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Can I use Visual Studio 2010 to debug javascript and let me stop and watch variables? - Stack Overflow

programmeradmin0浏览0评论

I'm using VS2010. I have javascript visible and I placed a breakpoint in a function like below:

function 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

I'm using VS2010. I have javascript visible and I placed a breakpoint in a function like below:

function 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

Share Improve this question edited Dec 18, 2011 at 4:31 Joel Coehoorn 416k114 gold badges578 silver badges813 bronze badges asked Apr 22, 2011 at 8:37 Melova1985Melova1985 4072 gold badges5 silver badges5 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

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.

发布评论

评论列表(0)

  1. 暂无评论