Dav*_*der 6 javascript php syntax-highlighting ace-editor
我正在制作一个小型网络应用程序,允许用户通过Ace Editor提交html,css和javascript内容.在这个编辑器中,将存储的内容回显到编辑器中就足够了,但无论如何我都找不到向数据库提交用户输入.我可以看到有一个由JavaScript生成的textarea然而我不确定它在做什么,如何到达它或者我是否应该完全寻找其他东西.
我主要是在寻找一个可以用来将php提交到数据库中的字段或东西.
Pau*_*ien 15
使用会话getValue方法可以使用编辑窗口的内容.例如,以下是保存文件的标准ACE演示的扩展:
saveFile = function() {
var contents = env.editor.getSession().getValue();
$.post("write.php",
{contents: contents },
function() {
// add error checking
alert('successful save');
}
);
};
Run Code Online (Sandbox Code Playgroud)
我将saveFile调用添加到demo.js中已存在的"假保存"中.我用这样的代码替换警报:
// 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();
}
});
Run Code Online (Sandbox Code Playgroud)
php文件只有一行:
$r = file_put_contents("foo.txt", $_POST["contents"]) or die("can't open file");
| 归档时间: |
|
| 查看次数: |
8016 次 |
| 最近记录: |