How to use ckeditor in php using ajax?

View Page

File Name : index.php

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.ckeditor.com/4.15.0/standard/ckeditor.js"></script>
<script>
$(document).ready(function(){
$("#save").click(function(){
var Content = CKEDITOR.instances['Content'].getData();
$.ajax({
url: "save.php",
type: "POST",
data: {
Content: Content
},
cache: false,
success: function(dataResult){
var dataResult = JSON.parse(dataResult);
if(dataResult.statusCode==200){

$('#success').html('Data Saved successfully !');
}
else if(dataResult.statusCode==201){
alert("Error occured !");
}

}
});
});
CKEDITOR.replace('Content');
});
</script>
</head>
<body>
<textarea name="Content" id="Content" placeholder="Required, at least 4 characters"></textarea><br>
<button type="button" id="save">Save</button>
</body>
</html>


File Name : save.php


<?php
echo $_POST['Content'];
?>





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here