如何从jQuery AJAX收到的脚本中看到运行时错误?
我正在编写一个(自由软件)应用程序(MELT监视器,在GNU / Linux / Debian / x86-64上),它embedded了特定的Web服务器。 看到这个问题的细节。 我在提交d624e22497de …
在Linux / Debian / Gnu / x86-64上使用最新的Firebug Firefox 38或42。
我正在使用一个jQuery的$.ajax脚本:
如何保存所有的二进制Web浏览器的stream量
Firebug在哪里安装?
该站点指定了无效的Strict-Transport-Security标头 – 萤火虫
Mozilla Firefox的命令行安装Selenium Scraping
$.ajax ({url: "/canvasedit",method: "POST",data: {"do_fillcanvas": true},dataType: "script",success: ajaxcanvascript });
正确调用ajaxcanvascript (并显示console.log ),所以从HTTP的angular度来看,AJAX请求已成功(200 OK)。
但是,当由do_fillcanvas收到的AJAX脚本中存在运行时错误时,这是一个类似于以下内容的生成脚本:
console.log('dofillcanvas canvedit.c:206 siz 1; this=',this,' momc_display_canvas=',momc_display_canvas); momc_display_canvas('09:26:39',[ momc_top_entry(momc_item_ref('notice'),momc_node(momc_item_ref('comment'),[ momc_string("some simple notice"),momc_node(momc_item_ref('web_state'),[ momc_int(2)]),momc_item_val('hashset'),momc_set([ momc_item_ref('canvasedit'),momc_item_ref('microedit'),momc_item_ref('the_agenda')]),momc_tuple([ momc_item_ref('web_session'),momc_nil_ref(),momc_item_ref('the_system')]) ]))]); console.log('dofillcanvas canvedit.c:239 this=',this); addupdatehtml('displayed <tt>Sat Nov 7 09:26:39 2015 MET</tt>'); console.log('dofillcanvas canvedit.c:252 done 09:26:39.11 this=',this);
我的Firebug控制台中没有任何错误信息(或从Firefox中看不到任何错误消息)。
我正在debugging的那种运行时错误是,例如一些从momc_display_canvas (使用jcanvas ,我不是很熟悉)深度的未定义的方法。
那么, 如何从jQuery AJAX接收的脚本中轻松地看到运行时错误?
我添加console.log无处不在,但这是不方便的…
如果我是正确的,那么你是要求处理错误,同时调用ajax到ajax完成。 jQuery的ajax有一个错误的参数回调函数,您可以使用该回调来处理您的错误。
$.ajax({ ... error: function(error){ console.log(error); } ... })
如果你想处理总的错误,你可以使用围绕总的ajax调用的try catch块。希望这将帮助你})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。