Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-24-2008, 03:33 PM   PM User | #1
kokjj87
Regular Coder

 
kokjj87's Avatar
 
Join Date: Sep 2008
Location: Singapore
Posts: 279
Thanks: 1
Thanked 55 Times in 54 Posts
kokjj87 is on a distinguished road
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
kokjj87 is offline   Reply With Quote
Old 09-24-2008, 03:44 PM   PM User | #2
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
is it sending them through url encoded?

http://us2.php.net/manual/en/function.urldecode.php
ohgod is offline   Reply With Quote
Old 09-24-2008, 03:49 PM   PM User | #3
kokjj87
Regular Coder

 
kokjj87's Avatar
 
Join Date: Sep 2008
Location: Singapore
Posts: 279
Thanks: 1
Thanked 55 Times in 54 Posts
kokjj87 is on a distinguished road
is anyway to do it in javascript- prototype?
kokjj87 is offline   Reply With Quote
Old 09-24-2008, 03:53 PM   PM User | #4
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
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).
ohgod is offline   Reply With Quote
Old 09-24-2008, 03:57 PM   PM User | #5
kokjj87
Regular Coder

 
kokjj87's Avatar
 
Join Date: Sep 2008
Location: Singapore
Posts: 279
Thanks: 1
Thanked 55 Times in 54 Posts
kokjj87 is on a distinguished road
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...
kokjj87 is offline   Reply With Quote
Old 09-24-2008, 04:02 PM   PM User | #6
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
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.
ohgod is offline   Reply With Quote
Old 09-24-2008, 04:08 PM   PM User | #7
kokjj87
Regular Coder

 
kokjj87's Avatar
 
Join Date: Sep 2008
Location: Singapore
Posts: 279
Thanks: 1
Thanked 55 Times in 54 Posts
kokjj87 is on a distinguished road
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..
kokjj87 is offline   Reply With Quote
Old 09-24-2008, 04:19 PM   PM User | #8
kokjj87
Regular Coder

 
kokjj87's Avatar
 
Join Date: Sep 2008
Location: Singapore
Posts: 279
Thanks: 1
Thanked 55 Times in 54 Posts
kokjj87 is on a distinguished road
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..
kokjj87 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:48 AM.


Advertisement
Log in to turn off these ads.