Results 1 to 3 of 3

Thread: AJAX autosuggest problem in Opera (PLZ help)

  1. #1
    Join Date
    Jun 2009
    Posts
    2

    AJAX autosuggest problem in Opera (PLZ help)

    Hello, everyone...

    So, I've got this problem I can't decide, maybe there is someone smarter or more experienced who can help me .

    On my web-site I'm using auto-suggest live-search field which works like a charm in every browser besides Opera (( In Opera when I type something the search gives me multiple results. for example if I search the word "home", in results it shows me "home" 4 times. (((

    I'm using linux server and here are the scripts which I'm using for live search:

    This is ajax code in js file:
    Code:
    function Initialize()
    {
    try
    {
    http=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
    try
    {
    http=new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(oc)
    {
    http=null;
    }
    }
    
    if(!http&&typeof XMLHttpRequest!="undefined")
    {
    http=new XMLHttpRequest();
    }
    }
    function createObject() {
    var request_type;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer")
    {
    request_type = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
    request_type = new XMLHttpRequest();
    }
    return request_type;
    }
    var XMLHttp = createObject();
    function autosuggest() {
    Initialize();
    var q = null;
    var q = encodeURIComponent(document.getElementById("search-q").value);
    nocache = Math.random();
    XMLHttp.open("get","english_search.php?q="+q+"&&nocache="+nocache);
    XMLHttp.onreadystatechange = autosuggestReply;
    XMLHttp.send(null);
    }
    function hileload()
    {
    document.getElementById("results").style.display = "none";
    }
    function autosuggestReply() {
    Initialize();
    if(XMLHttp.readyState == 2)
    {
    }
    if (XMLHttp.readyState == 4)
            {
    hileload();
    
    if (XMLHttp.status == 200)
    {
    var response = XMLHttp.responseText;
    e = document.getElementById("results");
    if(response!=="");{
    e.innerHTML=response;
    e.style.display="block";
    }
    }
    }
    }
    and here is .php file code for mysql database:
    Code:
    <?php 
    include('config.php'); 
    ?>
    <?php
    $SQL_FROM = 'eng';
    $SQL_WHERE = 'english';
        $q = rawurldecode($_GET['q']);
    $searchq = strip_tags($_GET['q']);
    $getRecord_sql = 'select * from '.$SQL_FROM.' where '.$SQL_WHERE.' like "'.$searchq.'%" LIMIT 7';
    $characterSet = mysql_query;
    if(!$characterSet){ 
       die ('Can\'t set character set : ' . mysql_error());
    }
    $mysql_query = mysql_query("SET NAMES 'utf8'") or die ("Error".mysql_error());
    $mysql_query = mysql_query("SET CHARACTER SET 'utf8'")or die ("Error".mysql_error());
    
    $getRecord=mysql_query($getRecord_sql);
    
    if(strlen($searchq)>0){
    echo '<ul>';
    while ($row = mysql_fetch_array($getRecord)) {?>
    <li>
    <font style="color:#0000FF; font-weight:bold; font-size:17px;"><?php echo $row['test1']; ?></font>
    <font style="color:#00CC33; font-weight:bold;"><i><?php echo $row['test2']; ?></i></font>
    
    </li>
    <?php } 
    echo '</ul>';
    ?>
    <?php } ?>
    So, please help me someone and let me know if you need some more information on it. Oh, by the way, just for record: on localhost the search doesn't have any problem but after I uploaded it on my linux server I had to face this problem ((( Maybe just because the localhost works very fast... I don't know (( I have spent 2 weeks on this issue and can't fix it. So, sos

  2. #2
    Join Date
    Jun 2006
    Posts
    623

    Re: AJAX autosuggest problem in Opera (PLZ help)

    Are you getting any errors?
    where are you calling suggest from?

    Code:
    ...
    var minChars=3;//execute only if at least three characters have been typed.
     
    function suggest(input){
      if( minChars > String(input).length )
        return;
     
     //encode value
     input = encodeURIComponent(input);
            xmlHttp=GetXmlHttpObject();
            if (xmlHttp==null) {
                    alert ("Browser does not support HTTP Request");
                    return;
            }
            var url="index.php?action=SearchSuggest&amp;query="+input;
            xmlHttp.onreadystatechange=stateChanged;
            xmlHttp.open("GET",url,true);
            xmlHttp.send(null);
    }
     
    ...

  3. #3
    Join Date
    Jun 2009
    Posts
    2

    Re: AJAX autosuggest problem in Opera (PLZ help)

    Thank you so much Gusgr8 for your answer.

    No I don't get any errors. All that happens is that in Opera my auto-suggest gives me multiple results. For example when I type word "home" in search, it shows me 4 results for "home" while it should be showing only one. This happens when I type fast , if i type slowly it gives me only one result as it's supposed to be.

    I'm calling the suggest from php file:
    Code:
    <div id="search-wrap">
      <input id="search-q" onKeyUp="javascript:autosuggest()" name="search-q" type="text";/>
    <div id="results"></div>
    </div>
    It doesn't show me any errors... everything works just like it should be. Only in opera I had to face this issue and in FF sometimes it doesn't show me results automatically if I don't hit "Enter" after the word is typed. I'm very new in AJAX so I'm very lost here and can't realize what to do

Similar Threads

  1. Opera problem in micromax q5
    By Luz in forum Portable Devices
    Replies: 10
    Last Post: 06-07-2010, 11:53 PM
  2. jQuery AJAX vs. Adobe AIR AJAX Class
    By Agaev in forum Windows Software
    Replies: 5
    Last Post: 06-07-2010, 01:59 PM
  3. AutoSuggest Drop-Down: iexplore.exe
    By Gamer001 in forum Technology & Internet
    Replies: 3
    Last Post: 19-08-2009, 11:40 PM
  4. Remove Firefox AutoSuggest text
    By Deep123 in forum Technology & Internet
    Replies: 3
    Last Post: 10-04-2009, 03:07 PM
  5. AJAX mootools Fx.Tween problem
    By CitricAcid in forum Software Development
    Replies: 4
    Last Post: 17-01-2009, 07:22 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,289,919.47640 seconds with 17 queries