js_280 Posted May 22, 2007 Share Posted May 22, 2007 I'm new to AJAX and using the following code for a autocomplete field works in Firefox, however, only the first letter that is entered is recognized in IE 6 and 7 Here's the code... <script type="text/javascript" language="javascript"> var XMLRequest = false; try { XMLRequest = new XMLHttpRequest(); } catch(e) { try { XMLRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e2) { try { XMLRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e3) { alert("Not AJAX compatible!"); } } } function sendRequest() { var search = false; search = document.getElementById('search').value; if(search != "") { var url = "./dynamic_lookup_script.php?search=" + escape(search); document.getElementById('display_div').style.visibility = "visible"; XMLRequest.onreadystatechange = function() { if(XMLRequest.readyState == 4) { document.getElementById('display_div').innerHTML = XMLRequest.responseText; } } XMLRequest.open("GET", url, true); XMLRequest.send(null); } else { document.getElementById('display_div').style.visibility = "hidden"; } } </script> </head> <body onload="document.getElementById('search').focus(); document.getElementById('search').value = '';"> Customer Name: <input type="text" name="search" id="search" onkeyup="sendRequest();" /><br /> <div id="display_div" style="padding: 10px; width: 300px; left: 124px; height: auto; position: absolute; background-color: #DDDDFF; border: 1px solid #0066FF; font-size: 10px; font-weight: bold; visibility: hidden;"></div> When you enter the first letter into the search field, it will pull the first query. After that, the display doesn't update in IE. Is there something else other than onkeyup() I should be using to query on every keypress? Thanks for the help! Quote Link to comment Share on other sites More sharing options...
emehrkay Posted May 22, 2007 Share Posted May 22, 2007 its not the event that is causing the problem, it is the way ie handles the requests. Look into using a framework that caches the ajax requests, like mootools or the yahoo one Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.