Advertisement
Guest User

Untitled

a guest
Mar 29th, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. <!doctype html>
  2. <head>
  3. <title>AJAX-Requests vs. Firefox v11</title>
  4. <style type="text/css">
  5. #test {width:800px; margin-left:auto; margin-right:auto;}
  6. h1 {text-align:center;}
  7. p {font-size:20px; padding:10px 100px 10px 100px;}
  8. p.left {text-align:left;}
  9. p.right {text-align:right;}
  10. </style>
  11. </head>
  12. <body>
  13. <div id="test">
  14. <h1>Loading this page with FF11 the second ajax response won´t arrive.</h1>
  15. </div>
  16. <script type="text/javascript">
  17. var xmlHttp;
  18.  
  19. try { xmlHttp = new XMLHttpRequest(); } //Firefox, Opera 8.0+, Safari
  20. catch(e) { //Internet Explorer
  21. try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  22. catch(e) {
  23. try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  24. catch(e) {
  25. alert("Your browser does not support AJAX! " + e.getMessage())
  26. xmlHttp = false;
  27. }
  28. }
  29. }
  30. xmlHttp.open('POST', 'test.html', true);
  31. xmlHttp.onreadystatechange = function () {
  32. if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
  33. document.getElementById("test").innerHTML += "<p class='right'>The first response arrives</p>";
  34. xmlHttp.open('POST', 'test.html', true);
  35. xmlHttp.onreadystatechange = function () {
  36. if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
  37. document.getElementById("test").innerHTML += "<p class='right'>...but the second response is for non-FF11 Users only</p>";
  38. }};
  39. document.getElementById("test").innerHTML += "<p class='left'>The second request is sent...</p>";
  40. xmlHttp.send();
  41. }};
  42. document.getElementById("test").innerHTML += "<p class='left'>The first request is sent</p>";
  43. xmlHttp.send();
  44. </script>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement