保存数据到PHP / MySQL的在CKEditor的联编辑 [英] Save data to PHP / Mysql with inline edit in CKEditor

查看:458
本文介绍了保存数据到PHP / MySQL的在CKEditor的联编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用新的CKEditor 4的内联编辑( HTTP ://docs.ckeditor.com/# /引导/ dev_inline节-2 ),但无法找到如何保存数据用PHP / MySQL的任何实际的例子! 你能帮助我吗?

I want to use "inline edit" of the new CKEditor 4 (http://docs.ckeditor.com/#!/guide/dev_inline-section-2), but can not find any example of how to save the data with PHP / MySQL. Can you help me?

推荐答案

这是我的样子已经在过去做到了:

This is the way I've done it in the past:

current_page_id 涉及到我们要更新的表行,否则我们也不会知道我们需要更新什么记录。

The current_page_id relates to the table row we wish to update, otherwise we wouldn't know what record we need to update.

<div id="editable">My body text</div>
<input type="hidden" name="page_id" id="current_page_id" value="10" />

<script type="text/javascript">

CKEDITOR.disableAutoInline = true;
CKEDITOR.inline('editable', {
    on: {
        blur: function( event ) {

            var params = {
                page_id: $("#current_page_id").val(),
                body_text: event.editor.getData()
            };

            $.ajax({
                url: 'php_file_to_post_to.php',
                global: false,
                type: "POST",
                dataType: "text json",
                data: params,
                success: function(result) {
                    console.log(result);
                }
            });

        }
    }
});

</script>

你的 php_file_to_post_to.php PHP文件的内部,你只是赶上了ajax post请求和更新基于关闭 PAGE_ID 变量,它也被张贴随着编辑的内容。

The inside of your php_file_to_post_to.php PHP file you simply catch the ajax post request and update the row based off of the page_id variable which has also been posted along with the edited content.

这篇关于保存数据到PHP / MySQL的在CKEditor的联编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆