Ajax livesearch weird behavior...

Discussion in 'JavaScript' started by clix99, Dec 10, 2011.

  1. #1
    Hi,

    I used the code on the following example:
    http://www.w3schools.com/php/php_ajax_livesearch.asp

    Instead of xml I use mysql but it works the same way.


    My problem is with this character '#' (shift 3 - on my keyboard).
    Some of the words in my database table contain this character but when I type it, it acts like nothing was typed.

    Any idea on what to do to make this work like any other character?

    Thanks
     
    clix99, Dec 10, 2011 IP
  2. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #2
    you need to use.. encodeURIComponent

    add this part before xmlhttp.open
    
    str = encodeURIComponent(str);
    
    Code (markup):
     
    JohnnySchultz, Dec 12, 2011 IP