I have a problem with contenteditable .
Before i used textarea for sending posts for text. I want to change it now to use contenteditable.
So contenteditable doesn't allow to send php strings from data. For example
In this demo i will show you my html and ajax codes. That is working perfectly, if user send normal text. But if user want to share php codes from his friends like (<?php echo 'Hi There.';?>) then problem will be come here. If user write normal text like (Hi There.) then not have any problem.
Normaly we are using val(); if we use textarea like this
var updateText = $('#post-text-area').val();
I think problem will be come here but i am not sure.
use with encodeURIComponent() .it will prevent the tag's passing from html to php .And retrieve the data from php use with decodeURIComponent()
$(document).ready(function() {
$("body").on("click", ".sendPost", function() {
var updateText = $('#post-text-area').html();
var dataString = 'update=' + encodeURIComponent(updateText);
$.ajax({
type: 'POST',
url: '/posttext.php',
data: dataString,
beforeSend: function() {},
success: function(html) {
decodeURIComponent(html);
}
});
});