ajaxutils.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: ps
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2011
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  9. // Cognos and the Cognos logo are trademarks of Cognos Incorporated.
  10. var xmlHttpVersions = [
  11. "Msxml2.XMLHTTP.6.0",
  12. "Msxml2.XMLHTTP.3.0",
  13. "Msxml2.XMLHTTP",
  14. "Microsoft.XMLHTTP"
  15. ];
  16. function findXMLHttpActiveXVersion() {
  17. if (window.ActiveXObject) {
  18. var i, l = this.xmlHttpVersions.length;
  19. for (i = 0; i < l; i++) {
  20. try {
  21. // Try and create the ActiveXObject for Internet Explorer, if it doesn't work, try again.
  22. var xmlhttp = new ActiveXObject(this.xmlHttpVersions[i]);
  23. if (xmlhttp)
  24. return this.xmlHttpVersions[i];
  25. } catch (e) {
  26. // this ActiveX is not there, continue with next one in list
  27. }
  28. }
  29. }
  30. return null;
  31. }
  32. var xmlHttpDefault = findXMLHttpActiveXVersion();
  33. function getXMLHttpRequest() {
  34. if (xmlHttpDefault != null)
  35. return new ActiveXObject(xmlHttpDefault);
  36. // Well if there is no ActiveXObject available it must be firefox, opera, or something else
  37. if (typeof XMLHttpRequest != 'undefined') {
  38. try {
  39. return new XMLHttpRequest();
  40. } catch (e) {
  41. alert(e);
  42. }
  43. }
  44. throw "No XMLHttpRequest object is available";
  45. }