3

I have an ajax call that returns a html view like so:

$.ajax({
            url: 'process.php',
            type: 'post',
            data: {
                action: "data",
                view:"data",
            },
            success: function (data) {
                $("#someDiv").html(data);
            }
        });

The view contains some javascript like so:

<script type="text/javascript">
    $(document).ready(function () { 
        var x = $("#something").val();
    });
 </script>

Now, is there a way to set a breakpoint on the line var x = $("#something").val(); in Chrome's debugger? If not, is there any other way to debug this kind of code? at the moment im only using alert()'s.

Thanks in advance

Notaras
  • 611
  • 1
  • 14
  • 44
  • 1
    Just add `debugger;` above that line? – Felix Kling Apr 30 '15 at 00:57
  • Thank you thats what i was after. I usually add breakpoints through the graphical interface not programmatically – Notaras Apr 30 '15 at 01:02
  • There are many anwsers alreay, please check[Set a breakpoint in XHR in Chrome][1] or [How do I debug Javascript which was loaded via AJAX (specifically jQuery)][2] [1]: https://stackoverflow.com/questions/3249696/set-a-breakpoint-in-xhr-in-chrome [2]: https://stackoverflow.com/questions/13129904/how-do-i-debug-javascript-which-was-loaded-via-ajax-specifically-jquery – jack-nie Apr 30 '15 at 01:03

1 Answers1

5

use debugger

debugger; //this will stop and pause your project
var x = $("#something").val();
yangli-io
  • 16,760
  • 8
  • 37
  • 47