Posted By

jlvallelonga on 02/17/09


Tagged

get http ajax object


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

umang_nine
cjwilburn
wirenaught


get http object


 / Published in: JavaScript
 

this funciton returns an XMLHttpRequest object for use in ajax pages

  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  

You need to login to post a comment.