I have a page with a summernote editor, when the user submits the page I retrieve the code from the editor through jquery and then send it to a php page which will then insert the html into a database. The html which I retrieve from the editor before I send it to the php page is correct, but as soon as it arrives at the php page most of the html is stripped down and incomplete.
This is my Summernote
<div class="summernote" id="decription" name="description"></div>
$('.summernote').summernote({
dialogsInBody: true,
toolbar: [
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['height', ['height']],
['undo', ['undo']],
['redo', ['redo']],
['help', ['help']]
],
placeholder: 'Describe the business here',
tabsize: 2,
height: 200
});
$('.dropdown-toggle').dropdown()
This is how I get the code from the editor once the user has submitted the page
var description = $("#decription").summernote('code');
I then post this description to my php page to insert the data into the database
var dataString = 'desc=' + description;
alert(dataString);
$.ajax({
type: "POST",
url: "../scripts/add/addpro.php",
data: dataString,
cache: false,
success: function(html) {
alert(html);
}
});
I do an alert before posting to make sure that the code sent to php is everything that is in the editor (just for testing), this is always correct and complete, the code sent to php is everything in the editor.
In my addpro.php page I do the following
$description = $_POST['desc'];
echo $description;
The html code echo'd by the php is incomplete and stripped down. Whenever for example there is a comma (,) in the html code, php will only go up to that and skip the rest of the tags and text after that.
Just update as shown
Update var dataString = 'desc=' + description;
to var dataString = {desc: description};