Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Web应用程序中的Ace编辑器_Php_Javascript_Syntax Highlighting_Ace Editor - Fatal编程技术网

PHP Web应用程序中的Ace编辑器

PHP Web应用程序中的Ace编辑器,php,javascript,syntax-highlighting,ace-editor,Php,Javascript,Syntax Highlighting,Ace Editor,我正在制作一个小型web应用程序,允许用户通过提交html、css和javascript内容。在这个编辑器中,将存储的内容回显到编辑器中就足够了,但是我无论如何都找不到向数据库提交用户输入的方法。我可以看到JavaScript生成了一个textarea,但是我不确定它在做什么,如何找到它,或者我是否应该完全寻找其他东西 我主要是寻找一个字段或一些我可以用来让php提交到db中的东西。编辑窗口的内容可以通过session getValue方法获得。例如,下面是标准ACE demo For save

我正在制作一个小型web应用程序,允许用户通过提交html、css和javascript内容。在这个编辑器中,将存储的内容回显到编辑器中就足够了,但是我无论如何都找不到向数据库提交用户输入的方法。我可以看到JavaScript生成了一个textarea,但是我不确定它在做什么,如何找到它,或者我是否应该完全寻找其他东西


我主要是寻找一个字段或一些我可以用来让php提交到db中的东西。

编辑窗口的内容可以通过session getValue方法获得。例如,下面是标准ACE demo For save file的扩展:

saveFile = function() {
    var contents = env.editor.getSession().getValue();

    $.post("write.php", 
            {contents: contents },
            function() {
                    // add error checking
                    alert('successful save');
            }
    );
};
我在demo.js中已经存在的“假保存”中添加了saveFile调用。我用如下代码替换警报:

// Fake-Save, works from the editor and the command line.
canon.addCommand({
    name: "save",
    bindKey: {
        win: "Ctrl-S",
        mac: "Command-S",
        sender: "editor|cli"
    },
    exec: function() {
        saveFile();
    }
});
php文件只有一行:


$r=file\u放入内容(“foo.txt”,“$\u POST[“contents”])或死亡(“无法打开文件”)

太棒了。非常感谢。我在同一个页面上有三个编辑器,因此我已经可以看到如何使用您提供的AJAX post代码来区分它们<代码>var htmlContents=env.htmlEditor.getSession().getValue();var cssContents=env.cssEditor.getSession().getValue();var jsContents=env.jsEditor.getSession().getValue()