ajax Browser compatibility problem has always been a lot of students worry about, here is a good example you can refer to, I hope to help you!
Code as follows: <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> Untitled document </title> <script> window.onload = function () { var obtn = document.getElementById (' btn '); Obtn.onclick = function () { //1. Create Ajax objects // Only non-IE6 browsers var oajax = null; if (window) are supported. XMLHttpRequest) { Oajax = new XMLHttpRequest (); //alert (new XMLHttpRequest ()); }else{ // Supports only IE6 browser Oajax = new ActiveXObject ("Microsoft.XMLHTTP"); } . Connect the server, add a time parameter here, each access address is different, The browser does not use the buffer in the browser, but the //But the server side is not resolved this time Oajax.open ("Get", "a.txt?t=" + New Date (). GetTime (), true); //3. Send oajax.send (null); //4. Accept information Oajax.onreadystatechange = function () { //The interaction between the browser and the server, to whichStep, when equal to 4, the representative read completes the if (oajax.readystate==4) { //status code, only equals 200, the representative accepts the completion, and succeeds the if (oajax.status==200) { Alert ("Success" + Oajax.responsetext); }else{ alert ("Failed"); } } }; }; } ; </script> </head> <body> <input type= "button" value= "button" id= "btn "/> </body> </html>