0

i have a text field TinyMCE 4.0 i when i am posting html from this field using ajax i seem to be having a problem with the data not ending up server side

in Firefox firebug it shows i posted this data

 attendanceID=&noteID=&Category=2&date=20-May-2014&leave=<p>&nbsp;</p> <p>fxghdfhdsfhsdfhsdf</p>&prn=15407&act=edit

server side PHP

  print_r( $_POST['leave']);

It prints

 <p>

but when i post this

  attendanceID=&noteID=&Category=2&date=20-May-2014&leave=<p>fadsfdasfasdf</p>&prn=15418&act=edit

everything works as expected prints

 <p>fadsfdasfasdf</p>
Anthony
  • 801
  • 10
  • 20

2 Answers2

3

You need to have it properly url encoded. It hits &nbsp; and thinks you've started a new variable.

This question has some more detailed information - When are you supposed to use escape instead of encodeURI / encodeURIComponent?

If it's data that someone else is providing to you, you should use encodeURIComponent on each url parameter. This prevents them from sending something to the server you're not expecting.

Note: There is also encodeURI which encodes the whole URI, ignoring some characters that have meaning to the url.

Instead of leave=<p>&nbsp; you should have leave=%20

%20 is the url encoded value for a space

Community
  • 1
  • 1
Freddy
  • 442
  • 1
  • 6
  • 13
0

You need to make your post parameters URL encoded.

Try

encodeURIComponent for javascript

or

rawurlencode for PHP

Petros P
  • 99
  • 8