Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. /* http://microformats.org/wiki/rest/ahah */
  2. function ahah(url,target) {
  3.  
  4. // native XMLHttpRequest object
  5. //document.getElementById(target).innerHTML = '<img src="/openov/common/images/horloge.gif" alt="Chargement" />';
  6. if (window.XMLHttpRequest) {
  7. req = new XMLHttpRequest();
  8. req.onreadystatechange = function() {ahahDone(target);};
  9. req.open("GET", url, true);
  10. req.send(null);
  11. // IE/Windows ActiveX version
  12. } else if (window.ActiveXObject) {
  13. req = new ActiveXObject("Microsoft.XMLHTTP");
  14. if (req) {
  15. req.onreadystatechange = function() {ahahDone(target);};
  16. req.open("GET", url, true);
  17. req.send();
  18. }
  19. }
  20. }
  21. function ahahDone(target) {
  22. // only if req is "loaded"
  23. if (req.readyState == 4) {
  24. // only if "OK"
  25. if (req.status == 200 || req.status == 304) {
  26. results = req.responseText;
  27. document.getElementById(target).innerHTML = results;
  28. } else {
  29. document.getElementById(target).innerHTML="ahah error:\n" + req.statusText;
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement