Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to debug javascript embedded in view

I want to debug java-script or j-query embedded in the same view of razor page in google chrome

@section Scripts
{
<script type="text/javascript">
    $(document).ready(function ()
    {
        var myClass = new MyClass();
        myClass.DoSomeStuff();
    });
</script>
}

how to debug and put break point in google chrome. because i cannot find script in source tab?

like image 365
Ahmed Ramadan Avatar asked Dec 04 '25 12:12

Ahmed Ramadan


2 Answers

Did you try to add the word debugger into your code ? maybe it can help you.

<script type="text/javascript">
$(document).ready(function ()
{
    debugger
    var myClass = new MyClass();
    myClass.DoSomeStuff();
});

like image 139
Mr Milk Avatar answered Dec 07 '25 03:12

Mr Milk


In chrome dev tools there is a debug tool.

  1. Go to Dev Tools (F12)
  2. Go to the sources tab
  3. Choose the file you want to debug
  4. Choose breaking points, like this: enter image description here

  5. Press on F5 to start the debug mode.

  6. Press on F10 to see each interaction.
like image 43
tomer raitz Avatar answered Dec 07 '25 02:12

tomer raitz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!