Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ajaxCall(url, data, fnSuccess, dataType, fnFailure)
- {
- if (!fnFailure)
- {
- fnFailure = function(jqXhr)
- {
- var lastDitchHtml = window.getCriticalErrorDialog("An error occurred during the ajax call.");
- window.showCeebox(lastDitchHtml, 120, 350);
- };
- }
- var a = $('<a>', { href : url })[0];
- var startTime = getTimestampMilliseconds();
- $.ajax({
- cache : false,
- async : false,
- url : url,
- type : 'POST',
- dataType : dataType,
- data : data,
- success : fnSuccess,
- error : fnFailure
- });
- var endTime = getTimestampMilliseconds();
- var duration = endTime - startTime;
- window.ga('send', 'timing', 'AjaxCall', a.pathname, duration);
- }
- function getTimestampMilliseconds()
- {
- if (window.performance)
- {
- return window.performance.now();
- }
- else
- {
- return new Date().getTime();
- }
- }
- window.ga('send', {
- hitType : 'timing',
- timingCategory : 'AjaxCall',
- timingVar : a.pathname,
- timingValue : duration});
- window.ga('send', {
- 'hitType' : 'timing',
- 'timingCategory' : 'AjaxCall',
- 'timingVar' : a.pathname,
- 'timingValue' : duration});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement