November 16, 2009

BUG: searchReq.readyState1 on fast typing

In the SimpleSuggest Contribution for OsCommerce another bug has been registered by cezar99, thanks at this point. If you type fast in the search input box you get an alert:

searchReq.readyState1

At this moment I got no solution, the only way at the time is to change a function in your ajax_search.js.

Try tho remove the else condition in ajax_search.js in the function searchSuggest():
this will only hide the message!

Change:
//Called from keyup on the search textbox.
//Starts the AJAX request.
function searchSuggest() {
if (searchReq.readyState == 4 || searchReq.readyState == 0) {
var str = escape(document.getElementById('txtSearch').value);

searchReq.open("GET", 'searchSuggest.php?search=' + str, true);
searchReq.onreadystatechange = handleSearchSuggest;
searchReq.send(null);
}
else {
alert('searchReq.readyState' + searchReq.readyState);
}
}

To this:
//Called from keyup on the search textbox.
//Starts the AJAX request.
function searchSuggest() {
if (searchReq.readyState == 4 || searchReq.readyState == 0) {
var str = escape(document.getElementById('txtSearch').value);

searchReq.open("GET", 'searchSuggest.php?search=' + str, true);
searchReq.onreadystatechange = handleSearchSuggest;
searchReq.send(null);
}
}

An other little detail who do not work 100% correct at the moment is, if you have a product name including an ß and "Mark search char strong" is activated, the name of the product will be destroyed, cause ß contains an s.

I will correct these things in future.

Update: Other languages and special chars may also generate problems.


Try to use stripslashes instead of htmlentities in searchSuggest.php at this point the problem can be fixed, but my time today goes to the end...

//Return each product name seperated by a newline.
//echo stripslashes($suggest['pn']) . "\n";/*
echo SIMPLESUGGEST_MARK_SEARCH_CHAR == 'true' ?
str_replace($search,'' . $search . '',stripslashes($suggest['pn']) . "\n"):
stripslashes($suggest['pn']) . "\n";//*/





Keine Kommentare:

Kommentar veröffentlichen