get http object


/ Published in: JavaScript
Save to your folder(s)

this funciton returns an XMLHttpRequest object for use in ajax pages


Copy this code and paste it in your HTML
  1. function getHTTPObject() {
  2. var xmlhttp;
  3. /*@cc_on
  4. @if (@_jscript_version >= 5)
  5. try {
  6. xmlhttp = new ActiveXObject("Msxml2.ServerXMLHTTP.3.0");
  7. } catch (e) {
  8. try {
  9. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  10. } catch (E) {
  11. xmlhttp = false;
  12. }
  13. }
  14. @else
  15. xmlhttp = false;
  16. @end @*/
  17.  
  18. if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  19. try {
  20. xmlhttp = new XMLHttpRequest();
  21. } catch (e) {
  22. xmlhttp = false;
  23. }
  24. }
  25.  
  26.  
  27. return xmlhttp;
  28. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.