I have a Rails application which generate HTML like this:
<a href="/ReadItLater/stock?qid=5618572&" data-remote="true">stock it</a>
When I click on this link in browser I can get information about AJAX request on Firebug, on Console tab. I can see the respond of the request:
$("#stock_5618528").hide();
But how can I set breakpoint on this line and debug this code?
I have a Rails application which generate HTML like this:
<a href="/ReadItLater/stock?qid=5618572&" data-remote="true">stock it</a>
When I click on this link in browser I can get information about AJAX request on Firebug, on Console tab. I can see the respond of the request:
$("#stock_5618528").hide();
But how can I set breakpoint on this line and debug this code?
Share Improve this question edited Apr 11, 2011 at 8:40 ceth asked Apr 11, 2011 at 8:29 cethceth 45.3k63 gold badges188 silver badges300 bronze badges 4 |3 Answers
Reset to default 11If you change your response to include the debugger keyword it should hit that as a breakpoint. So in this case the response would be:
debugger;
$("#stock_5618528").hide();
Obviously don't forget to remove that when it goes live. :D
Also, since you're using firebug.
Try using using `console.log()'. It is extremely handy.
You can view your output after your script has executed rather than interrupting execution and then having to deal with ajax timeouts.
All you might need to do is..
$.ajax({
url: "...",
success: function(response){
console.log(response);
}
});
InfernalBadger responded with a solution for front-end/script debugging. If you're interested in debugging at the server side (ie in the Rails code), do the following
- Start webrick with:
rails server --debugger
- And add debugger in the rails code/view where you'd like it to breakpoint, reaching which you'll get a console with all the environment and context loaded up!
<% debugger %>
$("#stock_5618528").hide();
is the output from the server in response to the AJAX request? – lonesomeday Commented Apr 11, 2011 at 8:42