简体   繁体   English

调试Javascript挂起系统

[英]Debugging Javascript hangs system

I am working on a project using MVC and dropdown lists. 我正在使用MVC和下拉列表开发一个项目。 When the dropdown list changes, I have some javascript code that needs to execute. 下拉列表更改时,我有一些需要执行的JavaScript代码。 I started having trouble debugging it (system locked up everytime) so I created a stripped down, simple example to see where the problem is (sample is below). 我开始无法调试它(系统每次都锁定)所以我创建了一个简单的例子来查看问题所在(示例如下)。

When I run this code through IE 11, it works just fine. 当我通过IE 11运行此代码时,它工作得很好。 However, when I run this using the IE 11 developer tools (javascript debugger) and place a breakpoint within my select list change function, the debugger and IE hang. 但是,当我使用IE 11开发人员工具(javascript调试器)运行此操作并在我的选择列表更改功能中放置断点时,调试器和IE挂起。 Worse, I cannot close them as my system essentially hangs. 更糟糕的是,我无法关闭它们,因为我的系统基本上是挂起的。 The only way out is to log off or shutdown the machine manually. 唯一的出路是手动注销或关闭机器。 Has anyone run into this issue before? 有没有人遇到过这个问题? I have had 2 developers where I work try this and it breaks for them as well. 我有两个开发人员在我工作的地方尝试这个,它也会打破它们。

Interestingly, this can be debugged just fine in Google Chrome and Firefox. 有趣的是,这可以在谷歌Chrome和Firefox中进行调试。

<script src="~/Scripts/jquery-2.1.0.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $("#mySelect")
            .change(function () {
               var x = $(this).val(); // Breakpoint here
                $("#myTextbox").val(x);
            });

        $("#myTextbox")
            .change(function () {
                var x = $("#myTextbox").val();
                alert(x);
            });
    });
</script>

<select id="mySelect">
    <option value="hello">Hello</option>
    <option value="world">World</option>
</select>

<input type="text" id="myTextbox" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM