Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2008
    Location
    Philippines
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    My script doesn't work in IE!?

    Hello guys, I took a lot of hours to found out is the cause but I can't find it. It works fine in Firefox and Opera but the result doesn't shows in IE. Here's the javascript I use:
    PHP Code:
    function getXmlHttpRequestObject() {
        if (
    window.XMLHttpRequest) {
            return new 
    XMLHttpRequest();
        } else if(
    window.ActiveXObject) {
            return new 
    ActiveXObject("Microsoft.XMLHTTP");
        } else {
            
    alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
        }
    }

    var 
    searchReq getXmlHttpRequestObject();

    function 
    searchSuggest() {
        if (
    searchReq.readyState == || searchReq.readyState == 0) {
            var 
    str escape(document.getElementById('input').value);
            
    searchReq.open("POST"'/searchSuggest.php?search=' strtrue);
            
    searchReq.onreadystatechange handleSearchSuggest
            
    searchReq.send(null);
        }        
    }



    function 
    handleSearchSuggest() {
        if (
    searchReq.readyState == 4) {
            var 
    ss document.getElementById('search_suggest')
            
    ss.innerHTML '<font size="2" color="#5D6F73"><strong>Suggested</font>&nbsp;<font color="#353E47">Words</font></strong>';
            var 
    str searchReq.responseText.split("\n");
            for(
    i=0str.length 1i++) {
                
    //Build our element string.  This is cleaner using the DOM, but
                //IE doesn't support dynamically added attributes.
                
    var suggest '<div onmouseover="javascript:suggestOver(this);" ';
                
    suggest += 'onmouseout="javascript:suggestOut(this);" ';
                
    suggest += 'class="suggest_link"><img src="/images/bg/submenu1.gif" alt=">" width="6" height="5">&nbsp;&nbsp;';
                
    suggest += '<a href="/browse/' str[i] + '.html&new=1">';
                
    suggest += '' str[i] + '</a></div>';
                
    ss.innerHTML += suggest;
            }
        }
    }



    //Mouse over function
    function suggestOver(div_value) {
        
    div_value.className 'suggest_link_over';
    }
    //Mouse out function
    function suggestOut(div_value) {
        
    div_value.className 'suggest_link';
    }

    //Click function
    function setSearch(value) {
        
    document.getElementById('input').value value;
        
    document.getElementById('search_suggest').innerHTML '';

    This is referenced to this php script:
    PHP Code:
    //Send some headers to keep the user's browser from caching the response.
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); 
    header("Last-Modified: " gmdate"D, d M Y H:i:s" ) . "GMT" ); 
    header("Cache-Control: no-cache, must-revalidate" ); 
    header("Pragma: no-cache" );
    header("Content-Type: text/xml; charset=utf-8");

    //Get our database abstraction file
    require('searchdatabase_suggestion.php');
    ///Make sure that a value was sent.
    if (isset($_GET['search']) && $_GET['search'] != '') {
        
    //Add slashes to any quotes to avoid SQL problems.
        
    $search addslashes($_GET['search']);
        
    $search_nospace str_replace(" ""_"$search);
        
    //Get every page title for the site.
        
    $suggest_query db_query("SELECT distinct(word) as suggest FROM wn_synset WHERE word like('" 
            
    $search_nospace "%') ORDER BY word Limit 10");
        while(
    $suggest db_fetch_array($suggest_query)) {
            
    //Return each page title seperated by a newline.
            
    $query str_replace("_"" "$suggest['suggest']);
            echo 
    $query."\n";
        }

    Here's how the form was written:
    PHP Code:
    <input name="SearchWord" type="text" class="searchword" id="input" value="$word" onkeyup="searchSuggest();" autocomplete="off"
    Please help me guys. I am still a learner in AJAX so I hope you understand. Thank you!

    PS:
    By the way, it works in the IE if the page was refreshed else if the cookies were cleaned up and visited the page again it doesn't work again. It is weird.
    Last edited by DefineItFast; 07-03-2008 at 04:42 AM. Reason: Added more info
    Experience the fastest online dictionary in the net. Visit DefineItFast.com and you will see!:)

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Why are you using if (searchReq.readyState == 4 || searchReq.readyState == 0) { inside that function. It is not needed.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    try removing += and put = suggest+'ect...
    I been having this problem all day but this is a javascrip error not ajax (for futcher refferance)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •