如何在CKEditorsaving中使用内联编辑保存,删除,编辑数据到PHP / Mysql?

时间:2013-07-03 10:35:12

标签: php html mysql ajax ckeditor

我想使用新CKEditor 4(http://docs.ckeditor.com/#!/guide/dev_inline-section-2)的“内联编辑”,但找不到如何使用PHP / MySQL保存数据的任何示例。你能救我吗?

1 个答案:

答案 0 :(得分:1)

下面是一个如何从Ckeditor传递数据的示例。按下按钮,您可以通过ajax保存内容。

<div id="editable" contenteditable="true">
    <h1>Inline Editing in Action!</h1>
    <p>The div element that contains this text is now editable.
</div>
<button type='button' id='save'><span>Save</span></button>

<script>

   $(document).ready(function (e) {

      $("#save").click(function (e) {
          var data = CKEDITOR.instances.editable.getData();
          var options = {  
               url: "/path/to/php",
              type: "post",
              data: { "editor" : encodeUriComponent(data) },
             success: function (e) {
                 //code to do when success
             }

           };
      }
   });
</script>