使用 jsErrLog 分析 js 报错

1. github 地址:
https://github.com/Offbeatmammal/jsErrLog/tree/master/src

2. 在所有页面引入 jsErrLog,配置出错时打日志的 url
window.jsErrLog.url = "/jserr.html";

3. 配置 ajax 出错时打日志
;(function(){
	$(document).ajaxError(function(event, xhr, options){
		var msg = [];
		if(typeof xhr == "object"){
			msg.push('status:' + xhr.status);
			msg.push('statusText:' + xhr.statusText);
		}
		if(typeof options == "object"){
			msg.push('url:' + options.url);
			msg.push('data:' + options.data);
		}
		window.onerror('ajaxError:' + msg.join(';'));
	});
})();

  

posted @ 2016-09-09 17:50  xngeer  阅读(322)  评论(0)    收藏  举报