Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <head>
- <title>AJAX-Requests vs. Firefox v11</title>
- <style type="text/css">
- #test {width:800px; margin-left:auto; margin-right:auto;}
- h1 {text-align:center;}
- p {font-size:20px; padding:10px 100px 10px 100px;}
- p.left {text-align:left;}
- p.right {text-align:right;}
- </style>
- </head>
- <body>
- <div id="test">
- <h1>Loading this page with FF11 the second ajax response won´t arrive.</h1>
- </div>
- <script type="text/javascript">
- var xmlHttp;
- try { xmlHttp = new XMLHttpRequest(); } //Firefox, Opera 8.0+, Safari
- catch(e) { //Internet Explorer
- try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
- catch(e) {
- try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
- catch(e) {
- alert("Your browser does not support AJAX! " + e.getMessage())
- xmlHttp = false;
- }
- }
- }
- xmlHttp.open('POST', 'test.html', true);
- xmlHttp.onreadystatechange = function () {
- if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
- document.getElementById("test").innerHTML += "<p class='right'>The first response arrives</p>";
- xmlHttp.open('POST', 'test.html', true);
- xmlHttp.onreadystatechange = function () {
- if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
- document.getElementById("test").innerHTML += "<p class='right'>...but the second response is for non-FF11 Users only</p>";
- }};
- document.getElementById("test").innerHTML += "<p class='left'>The second request is sent...</p>";
- xmlHttp.send();
- }};
- document.getElementById("test").innerHTML += "<p class='left'>The first request is sent</p>";
- xmlHttp.send();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement