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 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2006
    Location
    I'm lost, livin inside myself
    Posts
    97
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem sending '#' via ajax

    I'm new to ajax, so I maybe making a simple mistake. But whenever I send a string from a form that contains a #, that and everything after it never makes it into the database.

    Can anyone tell me how to get around this?
    $guiness &= new sixpack();
    $guiness->chug();

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You should escape() the querystring you pass to the URL.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Mar 2006
    Location
    In an apartment.
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This helped me a lot- I was having a problem with linebreaks.

    I've noticed that even with escape() the + symbol gets lost (everything else stays the same, but + symbols become spaces). Are there any other symbols that won't work even with escape(), and how can we keep those as well?

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Use encodeURIComponent instead. Actually, there are 3 different methods of encoding the URL: escape, encodeURI and encodeURIComponent. See the difference here.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New Coder
    Join Date
    Mar 2006
    Location
    In an apartment.
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for that tip.

    In the description of encodeURIComponent() the article states
    the encodeURIComponent method encodes all characters
    however near the bottom it states
    encodeURIComponent() will not encode: ~!*()'
    What's up with that?

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Quote Originally Posted by djmonkey1 View Post
    Thanks for that tip.

    In the description of encodeURIComponent() the article states
    the encodeURIComponent method encodes all characters
    however near the bottom it states
    encodeURIComponent() will not encode: ~!*()'
    What's up with that?
    It means that it encodes all characters that are special in any way in a URI. However, the characters "~", "!", "*", "(", ")" and "'" have no special meaning in URI and don't need to be encoded.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

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