Create XMLHttpRequest


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



Copy this code and paste it in your HTML
  1. function createXMLHttpRequestObject() {
  2. var resObject = null;
  3.  
  4. try {
  5. resObject = new ActiveXObject("Mircosoft.XMLHTTP");
  6. window.console.log("Microsoft.XMLHTTP");
  7. }
  8.  
  9. catch (error) {
  10. try {
  11. resObject = new ActiveXObject("MSXML2.XMLHTTP")
  12. window.console.log("MSXML2.XMLHTTP");
  13. }
  14. catch(error) {
  15. try {
  16. resObject = new XMLHttpRequest();
  17. window.console.log("XMLHttpRequest");
  18. }
  19. catch (error) {
  20. alert("XMLHttpRequest-Objekt konnte nicht erzeugt werden.");
  21. }
  22. }
  23. }
  24.  
  25. return resObject;
  26. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.