Send catched ajax exception back to server to perform logging?

前提是你 提交于 2019-12-13 04:21:14

问题


i have an MVC3 application and i'm using Elmah to store the errors in a mysql database and even send those errors by email. This is working perfectly, now i have this javascript code in my main layout:

$(document).ajaxError(function (e, xhr, settings, exception) {
   //SEND BACK TO SERVER THE EXCEPTION
});

Now, what i want to do is to get the catched exception (the ajax exception) and send back to server to a method that stores that exception with Elmah. Is that possible? If it isn't what choice do i have?


回答1:


This following article shows some good guidance on how to log JavaScript errors back to Elmah:

Logging Errors with ELMAH in ASP.NET MVC 3 – Part 5 – (JavaScript)

I know the mechanism to report the error to the server is specific to MVC, but it should be easily adaptable to ASP.NET Web Forms as well if needed.



来源:https://stackoverflow.com/questions/16530358/send-catched-ajax-exception-back-to-server-to-perform-logging

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