Simple - Ajax Question - mysql/innerHTML issue with IE6? What's up. OK, I more or less am brand new to Ajax, so be easy I put together this quick form that allows a user to sign up - the data.php just basically checks a mysql db if the username exists, and either -if it doesn't exist - create an entry in the database with the username, pw, and email and echo "Congratulations, you are added"; -if it does exist - it echo "Sorry but 'xxx' is already taken, try again!"; This is the weird part though. This works perfect in FF, but IE6 has a weird issue (I only have IE6 here can't test anything else) - With IE6, if the page is freshly loaded, it gives me the correct message - that is, if i put a non-existent name in, it does the echo "Congratulations, you are added"; but if I click on submit again - it doesn't echo "Sorry but 'xxx' is already taken, try again!"; (it does on FF) - If I start a fresh page and input a name that's already in the database it does echo "Sorry but 'xxx' is already taken, try again!"; -- but if i change the username to something that doesn't exist - it doesn't change the echo (i.e. it still says "Sorry but 'xxx' is already taken, try again!"; - but the record is created in mysql! I hope this makes sense - thanks for any help! matRocka code: <html> <body> <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4) { var output = document.getElementById("output"); //response text is either Congratulations you signed up if there's no match, and sorry USERNAME is taken if there's a match output.innerHTML = ajaxRequest.responseText; } } var username = document.getElementById("user").value; var email = document.getElementById("email").value; var pw = document.getElementById("pw").value; var url = ""; var errormsg = ""; var error = 0; if (username == "") {error=1; errormsg = errormsg + "Please enter a username\n";} if (email == "") {error=1; errormsg = errormsg + "Please enter an email\n";} if (pw == "") {error=1; errormsg = errormsg + "Please enter a pw\n";} if (error == 1) { alert(errormsg); } else { url = "data.php?user=" + escape(username) + "&email=" + escape(email) + "&pw=" + escape(pw); ajaxRequest.open("GET", url, true); ajaxRequest.send(null); } } //--> </script> <form name='myForm'> <table> <tr> <td>Username</td><td><input type="text" name="user" id="user" /></td> </tr> <tr> <td>PW</td><td><input type="text" name="pw" id="pw" /></td> </tr> <tr> <td>E-mail</td><td><input type="text" name="email" id="email" /></td> </tr> <tr> <td colspan="2"><input type="button" name="button" value="Register" onclick="ajaxFunction();" style="width:100%;"></td> </tr> </table> <span name="output" id="output"></span><BR> <span name="output2" id="output2"></span><BR> </form> </body> </html> Code (markup):
Probably when IE6 came Internet was slow so IE6 tries to attain Max speed by using the cached data.!!!