Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. function ajaxCall(url, data, fnSuccess, dataType, fnFailure)
  2. {
  3. if (!fnFailure)
  4. {
  5. fnFailure = function(jqXhr)
  6. {
  7. var lastDitchHtml = window.getCriticalErrorDialog("An error occurred during the ajax call.");
  8. window.showCeebox(lastDitchHtml, 120, 350);
  9. };
  10. }
  11.  
  12. var a = $('<a>', { href : url })[0];
  13.  
  14. var startTime = getTimestampMilliseconds();
  15.  
  16. $.ajax({
  17. cache : false,
  18. async : false,
  19. url : url,
  20. type : 'POST',
  21. dataType : dataType,
  22. data : data,
  23. success : fnSuccess,
  24. error : fnFailure
  25. });
  26.  
  27. var endTime = getTimestampMilliseconds();
  28. var duration = endTime - startTime;
  29.  
  30. window.ga('send', 'timing', 'AjaxCall', a.pathname, duration);
  31. }
  32.  
  33. function getTimestampMilliseconds()
  34. {
  35. if (window.performance)
  36. {
  37. return window.performance.now();
  38. }
  39. else
  40. {
  41. return new Date().getTime();
  42. }
  43. }
  44.  
  45. window.ga('send', {
  46. hitType : 'timing',
  47. timingCategory : 'AjaxCall',
  48. timingVar : a.pathname,
  49. timingValue : duration});
  50.  
  51. window.ga('send', {
  52. 'hitType' : 'timing',
  53. 'timingCategory' : 'AjaxCall',
  54. 'timingVar' : a.pathname,
  55. 'timingValue' : duration});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement