|
Posted by gp on 10/12/06 13:09
This code is stopping ...I can't get past readyState == 1....
for testing purposes my searchDB.php is simply:
<?php
echo "string blahahahahah blahahaha hahahahhb ahaha";
?>
newK is <input id> it is dynamically created with php at the time the
form loads...there up to 28 <input>
that will have the google type search suggestion <div>. srchK is the
<div id> generated for each corresponding <input>
var xhr;
function XHR() {
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else if (window.ActiveXObject) {
xhr = new ActiveXObject(
"Microsoft.XMLHTTP");
}
return xhr;
}
function searchDB(newK, srchK) {
var http = XHR();
var str = escape($(newK).value);
http.open('POST', 'http://my.url.here/searchDB.php', true);
http.setRequestHeader("Content-type",
"application/x-www-form-urlencoded; charset=UTF-8");
http.onreadystatechange = handleSearchSuggest(http, newK,
srchK);
http.send(str);
}
function handleSearchSuggest(http, newK, srchK) {
var xhttp = http;
if (xhttp.readyState == 4) {
var ss = $(srchK);
ss.innerHTML = '';
var str = xhttp.responseText;//.split("\n");
var estr = eval(str);
alert (estr);
for (var i=0; i < estr.length - 1; i++ ) {
alert (i);
var suggest = '<div
onmouseover="javascript:suggestOver(this):" ';
suggest += 'onmouseout="javascript:suggestOut(this);"
';
suggest +=
'onclick="javascript:setSearch(this.innerHTML, '+newK+', '+srchK+');"
';
suggest += 'class="suggest_link">' + str[i] + '</div>';
ss.innerHTML += suggest;
}
}
Navigation:
[Reply to this message]
|