From ee647904b4234d8d8f70e3671f275de45dd50c8e Mon Sep 17 00:00:00 2001 From: Godwin Date: Mon, 16 Jan 2017 08:21:40 -0800 Subject: [PATCH] Fixed JS error reporting --- app/assets/javascripts/main.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index d467b08..feb2bb4 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -1,15 +1,15 @@ (function() { - window.onerror = function(message, url, lineNumber) { + window.onerror = function(message, url, lineNumber) { //save error and send to server for example. var request = new XMLHttpRequest(); - request.open('POST', '/js_error', true); - request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); - request.send( + var data = 'message=' + encodeURI(message) + '&url=' + encodeURI(url) + '&lineNumber=' + encodeURI(lineNumber) + - '&location=' + encodeURI(window.location.href) - ); + '&location=' + encodeURI(window.location.href); + request.open('GET', '/js_error?' + data, true); + request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + request.send(); return false; }; window.forEach = function(a, f) { Array.prototype.forEach.call(a, f) };