Hello guys, I took a lot of hours to found out is the cause but I can't find it. It works fine in Firefox and Opera but the result doesn't shows in IE. Here's the javascript I use: function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?"); } } var searchReq = getXmlHttpRequestObject(); function searchSuggest() { if (searchReq.readyState == 4 || searchReq.readyState == 0) { var str = escape(document.getElementById('input').value); searchReq.open("POST", '/searchSuggest.php?search=' + str, true); searchReq.onreadystatechange = handleSearchSuggest; searchReq.send(null); } } function handleSearchSuggest() { if (searchReq.readyState == 4) { var ss = document.getElementById('search_suggest') ss.innerHTML = '<font size="2" color="#5D6F73"><strong>Suggested</font> <font color="#353E47">Words</font></strong>'; var str = searchReq.responseText.split("\n"); for(i=0; i < str.length - 1; i++) { //Build our element string. This is cleaner using the DOM, but //IE doesn't support dynamically added attributes. var suggest = '<div onmouseover="javascript:suggestOver(this);" '; suggest += 'onmouseout="javascript:suggestOut(this);" '; suggest += 'class="suggest_link"><img src="/images/bg/submenu1.gif" alt=">" width="6" height="5"> '; suggest += '<a href="/browse/' + str[i] + '.html&new=1">'; suggest += '' + str[i] + '</a></div>'; ss.innerHTML += suggest; } } } //Mouse over function function suggestOver(div_value) { div_value.className = 'suggest_link_over'; } //Mouse out function function suggestOut(div_value) { div_value.className = 'suggest_link'; } //Click function function setSearch(value) { document.getElementById('input').value = value; document.getElementById('search_suggest').innerHTML = ''; } PHP: This is referenced to this php script: //Send some headers to keep the user's browser from caching the response. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); header("Cache-Control: no-cache, must-revalidate" ); header("Pragma: no-cache" ); header("Content-Type: text/xml; charset=utf-8"); //Get our database abstraction file require('searchdatabase_suggestion.php'); ///Make sure that a value was sent. if (isset($_GET['search']) && $_GET['search'] != '') { //Add slashes to any quotes to avoid SQL problems. $search = addslashes($_GET['search']); $search_nospace = str_replace(" ", "_", $search); //Get every page title for the site. $suggest_query = db_query("SELECT distinct(word) as suggest FROM wn_synset WHERE word like('" . $search_nospace . "%') ORDER BY word Limit 10"); while($suggest = db_fetch_array($suggest_query)) { //Return each page title seperated by a newline. $query = str_replace("_", " ", $suggest['suggest']); echo $query."\n"; } } PHP: Here's how the form was written: <input name="SearchWord" type="text" class="searchword" id="input" value="$word" onkeyup="searchSuggest();" autocomplete="off"> PHP: Please help me guys. I am still a learner in AJAX so I hope you understand. Thank you! PS: By the way, it works in the IE if the page was refreshed else if the cookies were cleaned up and visited the page again it doesn't work again. It is weird.
I modified the code so that I could test it in my environment and it works great in IE & Opera & Firefox. At the and of your post you're talking about cookies, but there's no cookies handling in the code. So, when it sometimes works and sometimes it doesn't and it's related to cookies, I can't help you until I see some cookies handling code, because obviously, it's somehow related to the cookies.
I doesn't use cookies for my site. Well I will try to look into it again, the error maybe somewhere. Thanks for testing it.
Well, it might be something with session. You said, it works when you refresh the page. Try to use local proxy or some monitoring utility and also custom logging in PHP script, to catch everything received and sent away, to see if there's any difference when it works and when it doesn't. Do same with Firefox and then compare the results.