Skip to content

Instantly share code, notes, and snippets.

@toygame
Created September 12, 2020 07:03
Show Gist options
  • Save toygame/e279b65ad2d713519044bea5cf3dd0eb to your computer and use it in GitHub Desktop.
Save toygame/e279b65ad2d713519044bea5cf3dd0eb to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel="stylesheet" href="/stylesheets/style.css" />
</head>
<body>
<h1><%= title %></h1>
<p>Welcome nodejs-tasmota</p>
<button id="butt_on">เปิด</button>
<button id="butt_off">ปิด</button>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$("#butt_on").click(function (event) {
event.preventDefault();
$.get("/control/on", function (data, status) {
alert("Data: " + data + "\nStatus: " + status);
});
});
$("#butt_off").click(function (event) {
event.preventDefault();
$.get("/control/off", function (data, status) {
alert("Data: " + data + "\nStatus: " + status);
});
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment