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 idit 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 idgenerated for each corresponding <input>
var xhr;
function XHR() {
if (window.XMLHttp Request) {
xhr = new XMLHttpRequest( );
} else if (window.ActiveX Object) {
xhr = new ActiveXObject(
"Microsoft.XMLH TTP");
}
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.setRequest Header("Content-type",
"applicatio n/x-www-form-urlencoded; charset=UTF-8");
http.onreadysta techange = handleSearchSug gest(http, newK,
srchK);
http.send(str);
}
function handleSearchSug gest(http, newK, srchK) {
var xhttp = http;
if (xhttp.readySta te == 4) {
var ss = $(srchK);
ss.innerHTML = '';
var str = xhttp.responseT ext;//.split("\n");
var estr = eval(str);
alert (estr);
for (var i=0; i < estr.length - 1; i++ ) {
alert (i);
var suggest = '<div
onmouseover="ja vascript:sugges tOver(this):" ';
suggest += 'onmouseout="ja vascript:sugges tOut(this);"
';
suggest +=
'onclick="javas cript:setSearch (this.innerHTML , '+newK+', '+srchK+');"
';
suggest += 'class="suggest _link">' + str[i] + '</div>';
ss.innerHTML += suggest;
}
}
for testing purposes my searchDB.php is simply:
<?php
echo "string blahahahahah blahahaha hahahahhb ahaha";
?>
newK is <input idit 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 idgenerated for each corresponding <input>
var xhr;
function XHR() {
if (window.XMLHttp Request) {
xhr = new XMLHttpRequest( );
} else if (window.ActiveX Object) {
xhr = new ActiveXObject(
"Microsoft.XMLH TTP");
}
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.setRequest Header("Content-type",
"applicatio n/x-www-form-urlencoded; charset=UTF-8");
http.onreadysta techange = handleSearchSug gest(http, newK,
srchK);
http.send(str);
}
function handleSearchSug gest(http, newK, srchK) {
var xhttp = http;
if (xhttp.readySta te == 4) {
var ss = $(srchK);
ss.innerHTML = '';
var str = xhttp.responseT ext;//.split("\n");
var estr = eval(str);
alert (estr);
for (var i=0; i < estr.length - 1; i++ ) {
alert (i);
var suggest = '<div
onmouseover="ja vascript:sugges tOver(this):" ';
suggest += 'onmouseout="ja vascript:sugges tOut(this);"
';
suggest +=
'onclick="javas cript:setSearch (this.innerHTML , '+newK+', '+srchK+');"
';
suggest += 'class="suggest _link">' + str[i] + '</div>';
ss.innerHTML += suggest;
}
}
Comment