Page 1 of 1

strange behavior for # sign

Posted: Sun Feb 22, 2009 9:10 pm
by wpsd2006
I created a form text area here

Code: Select all

 
<textarea id="notes"></textarea>
<input type="button" onclick="sendtext()" />
 
This is the javascript i'm using javascript prototype well you can care less about this
it's working 100% at this point

Code: Select all

 
function sendtext() {
alert($('notes').innerHTML); // the first alert the content of the notes before sending the data with ajax
new Ajax.Request ('ajax_notes.php',{
method: 'post',
parameters: 'v='+$('notes').innerHTML,
onComplete: function(resp) {
alert(resp.responseText) //It will alert the text on complete which is the text inside the text area
}
});
}
 
now this is the ajax_notes.php

Code: Select all

 
print_r($_POST);
 
Ok now when i submit the data like below

example 1
textarea: abcdefghijklmnopqrstu
1 alert: abcdefghijklmnopqrstu
2 alert: abcdefghijklmnopqrstu

example 2
textarea: abca###abc
1 alert: abca###abc
2 alert: abca

example 3
textarea: ###
1 alert: ###
2 alert:

now this is really strange behavior it seems the $_POST can't get the '#' string it delete the string that start with #
like example number 2
anyone ever get this problem
i don't know this is javascript problem or the php because on the 1st alert i still get the correct value even if it begin with ###

Re: strange behavior for # sign

Posted: Thu Mar 05, 2009 11:29 pm
by wpsd2006
looks it's javascript problem or maybe the php

when i change the # to %23 php parse it normal and get the # correctly

Re: strange behavior for # sign

Posted: Thu Mar 05, 2009 11:42 pm
by Benjamin
The # character is used to denote/specify an anchor in URIs so it does need to be converted into an entity. It's also used to denote the beginning of a comment line in PHP.