本文介绍了如何调试Ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Rails应用程序,生成HTML是这样的:
I have a Rails application which generate HTML like this:
<a href="/ReadItLater/stock?qid=5618572&" data-remote="true">stock it</a>
当我在浏览器中点击这个链接,我可以得到有关Ajax请求Firebug的,在控制台选项卡中的信息。我可以看到请求的响应:
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();
但我怎么可以设置断点在此行和调试该code?
But how can I set breakpoint on this line and debug this code?
推荐答案
如果你改变你的回应包括调试器关键字就应该打,作为一个断点。所以在这种情况下的反应是:
If 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();
显然不要忘了删除,当它开始运行。 :D
Obviously don't forget to remove that when it goes live. :D
这篇关于如何调试Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!