You are here: Re: readyState 1 wall « PHP Programming Language « IT news, forums, messages
Re: readyState 1 wall

Posted by Erwin Moller on 10/12/06 13:23

gp wrote:

> 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;
> }
> }


Hi,

Wrong group.
This is AJAX. Try comp.lang.javascript

Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация