Guest User

Untitled

a guest
Feb 18th, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. function createHTTP() {
  2. var http;
  3. try { // Firefox, Opera 8.0+, Safari et IE récent
  4. http=new XMLHttpRequest();
  5. } catch (e) { // Vieux IE
  6. try {
  7. http=new ActiveXObject("Msxml2.XMLHTTP");
  8. } catch (e) {
  9. try {
  10. http=new ActiveXObject("Microsoft.XMLHTTP");
  11. } catch (e) {
  12. http=null;
  13. }
  14. }
  15. }
  16. return http; // null si navigateur incompatible
  17. }
  18.  
  19. function handleResponse( http, id ) {
  20. if (http.readyState==4) {
  21. if (http.status == 0) {
  22. //200 pour http et 0 pour file
  23. var empXml = http.responseText;
  24. //Remplacez le child emp par celui du XML.
  25. var emp = document.getElementById("emp");
  26. emp.innerHTML = empXml;
  27. }
  28. }
  29. }
  30.  
  31. function include(id, xml) {
  32. var http = createHTTP();
  33. http.open("GET", xml, true);
  34. http.onreadystatechange = function(){handleResponse( http, id ); }
  35. http.send(null);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment