在firefox扩展中不能调试悬挂$ .post [英] can't debug hanging $.post in firefox extension

查看:173
本文介绍了在firefox扩展中不能调试悬挂$ .post的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发此扩展程序 https://builder.addons.mozilla.org / addon / 1022928 / latest /

此问题的中心代码是Data / panel.js
$ b $除了每当我点击Gem发布jquery调用,它只是挂在加载图标,我没有得到任何反馈在调音台为什么呼叫不去通过和正在处理,因为它应该。

那么如何使用新的Firefox附加SDK生成器测试版进行调试。我已经尝试写入console.log(),我已经读过它应该为其他人工作,但我真的不能看到我的任何日志消息,只是在代码中同步的错误,因此不是Ajax错误。

返回我的问题:如何在我的firefox扩展面板中调试悬挂的ajax调用?

解决方案

HTTPFox扩展显示您的请求已成功发送结果是 500内部错误响应。所以jQuery会调用一个错误回调 - 但是你没有给它(请参阅 jQuery.post()文档,第三个参数是 success 回调)。要定义一个错误回调,理想情况下应该使用 jQuery.ajax() method
$ b

  $。ajax({
键入:POST
url:url,
data {title:$(#txtTitle).val(),url:encodeURIComponent(taburl)},
success:function ,textStatus){
...
},
错误:function(data,textStatus){
...
}
});

或者您可以使用 request package 附加SDK提供了类似的API。

总结:由于没有错误,因此没有看到错误信息。如果出现错误,您应该确实希望在错误控制台中可以看到的异常,如果未被捕获的话。


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?

解决方案

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.

这篇关于在firefox扩展中不能调试悬挂$ .post的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆