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 8 of 8
  1. #1
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts

    Question prototype, how to post special characters?

    Hi, i am new to the prototype framework.. currently still learning on it... I have try to create a chat script.. but it seems like some of the character would not be passable to the php page via ajax..

    function addmessage(event)
    {
    var username = $F('name');
    var message = $F('message');
    var url = 'cbox.php';
    var pars = 'username=' + username + '&message=' + message;

    var myAjax = new Ajax.Request(
    url,
    {
    method: 'post',
    parameters: pars,
    onComplete: addcomplete
    });
    event.preventDefault();
    }

    Characters like #?%& are not able to be pass to the next page..
    Do i need to do some sort of encoding?.. so that the variable in the paramater would not conflict?

    thanks

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    is it sending them through url encoded?

    http://us2.php.net/manual/en/function.urldecode.php

  • #3
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    is anyway to do it in javascript- prototype?

  • #4
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    post sends it through like that to prevent syntax errors. assuming my guess was right and this is what you're fighting use that link i sent to decode it on the receiving end (inside cbox.php).

  • #5
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    I have try to using a input form ----> a html form posting to cbox.php
    but there is no error... it is not the php... there is something wrong with the parameters...

  • #6
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    ok... tell you what. let's eliminate the guesswork.

    get firefug for firefox, and monitor the post. relay the result here and we can take a look.

  • #7
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    hmm.. if i have special characters in either parameters.. firebug shows that what i have post after the special character is empty..
    Last edited by kokjj87; 09-24-2008 at 04:13 PM.

  • #8
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    Ok.. confrim is the parameter now..

    var pars = 'username=' + username + '&message=' + message;

    if i have the special characters in username.. text after the special characters and message would be blank...

    if it is the message that contain the special characters.. message after that would not be send via post..


  •  

    Posting Permissions

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