如何在Javascript中编写PHP以便我可以加载文件?或者,还有更好的方法?(我从服务器加载文本文件...所以我需要使用PHP来加载这些文件.我不知道如何处理PHP中的回调,但我可以用Javascript来完成.如果我能做的话,从那里开始从Javascript中的一些PHP,我可以解决我的问题.)
谢谢
desired sequence:
SaveButton
LoadButton
When the "load button" is pressed, load a textfile from the server into a textbox.
When the "save button" is pressed, save the textbox text to the server.
Run Code Online (Sandbox Code Playgroud)
您可以使用PHP来创建将用作JavaScript源的文件.
<script type="text/javascript" src="/my/js/file.php"></script>
Run Code Online (Sandbox Code Playgroud)
要么
<script type="text/javascript">
var str = '<?php echo 1+1;?>';
</script>
Run Code Online (Sandbox Code Playgroud)
PHP是服务器端.JavaScript是客户端.所以你不能在错误的平台上执行任何一种语言.