开发者

I am trying to do HTML and PHP to load and save a text file to the server

desired sequence:

SaveButton开发者_如何转开发

LoadButton When the "load button" is pressed, load a textfile from the server into a textbox.

Allow the user to add text

When the "save button" is pressed, save the textbox text to the server.

I am having issues with callbacks not executing.

I am worried about the callbacks, I know how to save a file.

<html>
<body>
<button id="1" onClick="reply_click(id)">Load</button>
<button id="2" onClick="reply_click(id)">Save</button>
<?php
function reply_click($clicked_id)
{
    echo "hello ";
}
?>
</body>
</html>


You're mixing JavaScript and PHP.

PHP is figured out and executed by the server. Then the web page is sent to the client. Then the user can interact with the page using JavaScript.

You'll have to change the onClick events to use AJAX that send a request to a PHP page.


You could use jQuery to handle AJAX requests without having to mess with low-level things like XMLHttpRequest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜