View Full Version : prototype, how to post special characters?

09-24-2008, 03:33 PM
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(
method: 'post',
parameters: pars,
onComplete: addcomplete

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?


09-24-2008, 03:44 PM
is it sending them through url encoded?


09-24-2008, 03:49 PM
is anyway to do it in javascript- prototype?

09-24-2008, 03:53 PM
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).

09-24-2008, 03:57 PM
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...

09-24-2008, 04:02 PM
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.

09-24-2008, 04:08 PM
hmm.. if i have special characters in either parameters.. firebug shows that what i have post after the special character is empty..

09-24-2008, 04:19 PM
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..