/* Global variables used for correct linking */ var web_urn = 'https://www.containerandpackaging.com/'; var sam_urn = 'https://sam.containerandpackaging.com/'; var api_url = 'https://api.containerandpackaging.com/'; /* Keep track of front-end errors */ var cps_log_500_error = function (errorResponseXmlText, description, errKey) { if (errKey == null && errorResponseXmlText != null) { try { var parser = new DOMParser(); var xmlDoc = parser.parseFromString(errorResponseXmlText, "text/xml"); var errKeyElement = xmlDoc.getElementsByName("error-key"); // a piece of meta data if (errKeyElement) { errKey = errKeyElement[0].content; } } catch (e) { description = description == null ? e : description; } } var data = { ErrKey: (errKey == null || errKey == "" ? 0 : errKey), FeedbackDescription: web_urn + " from-cps-javascript: " + (description == null ? "(none)" : description), Redirect: false } // Plain old javascript to log error. var xhr = new XMLHttpRequest(); xhr.open("post", api_url + 'customers/feedback/submitfeedback', true); xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); xhr.send(JSON.stringify(data)); }