Posted By

ddavidd on 10/07/10


Tagged

http httprequest


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

bobbym245


New Http Object


 / Published in: JavaScript
 

  1. /* Returns a HttpRequest object */
  2. function getHTTPObject() {
  3. try {
  4. // Opera 8.0+, Firefox, Safari
  5. return new XMLHttpRequest();
  6. } catch (e){
  7. // Internet Explorer Browsers
  8. try{
  9. return new ActiveXObject("Msxml2.XMLHTTP");
  10. } catch (e) {
  11. try{
  12. return new ActiveXObject("Microsoft.XMLHTTP");
  13. } catch (e){
  14. // Something went wrong
  15. alert("Your browser broke!");
  16. return false;
  17. }
  18. }
  19. }
  20. }

Report this snippet  

You need to login to post a comment.