石墨消解 mock
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
682 B

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. const ws = new WebSocket(`ws://${window.location.host}`);
  2. ws.onopen = () => {
  3. console.log("Connected to server");
  4. ws.send("Hello from client!");
  5. };
  6. ws.onmessage = event => {
  7. console.log(`Message from server: ${event.data}`);
  8. };
  9. ws.onclose = () => {
  10. console.log("Disconnected from server");
  11. };
  12. $("#moveArm").on("click", () => {
  13. const x = $("#armX").val();
  14. const y = $("#armY").val();
  15. const z = $("#armZ").val();
  16. $.ajax({
  17. type: "POST",
  18. url: "/api/debug/railArm",
  19. data: JSON.stringify({ x: +x, y: +y, z: +z }),
  20. contentType: "application/json",
  21. success: res => {
  22. console.log("Success", res);
  23. },
  24. error: err => {
  25. console.error("Error", err);
  26. },
  27. });
  28. });