can't debug hanging $.post in firefox extension

南笙酒味 提交于 2019-12-14 02:27:28

问题


I'm developing this extension https://builder.addons.mozilla.org/addon/1022928/latest/

The code central to this question is in Data/panel.js

And it's working pretty well, except that whenever I hit "Gem" to post a jquery call, it just hangs at the loading icon, I don't get any feedback in the console as to why the call is not going through and being processed as it should.

So how do I debug that with the new firefox add-on sdk builder beta. I've tried writing to console.log(), and I've read that it's supposed to work for others, but I really can't see any of my log messages, just errors that are synchronous in code, and hence not ajax errors.

Returning to my question: How do I debug a hanging ajax call in my firefox extension's panel?


回答1:


HTTPFox extension shows that your request was sent successfully and result is a 500 Internal Error response. So jQuery would have called an error callback - but you didn't give it any (see jQuery.post() documentation, the third parameter is the success callback). To define an error callback you should ideally use jQuery.ajax() method directly:

$.ajax({
  type: "POST"
  url: url,
  data {title:$("#txtTitle").val(), url:encodeURIComponent(taburl)},
  success: function(data, textStatus) {
    ...
  },
  error: function(data, textStatus) {
    ...
  }
});

Or you could use the request package of the Add-on SDK that provides similar API.

To sum up: you don't see an error message because there was no error. In case of errors you should indeed expect an exception that will be visible in Error Console if not caught.



来源:https://stackoverflow.com/questions/7949099/cant-debug-hanging-post-in-firefox-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!