当我从浏览器(作为本地主机)运行它时,标题中提到的以下代码可以正常工作,但是当我尝试从我在google驱动器中发布的文件中运行相同的网页时,它无法正常工作。该页面似乎已正确加载(外观),但不再起作用。
<html>
<head>
<title>ESP8266 LED Control</title>
</head>
<body>
<!-- in the <button> tags below the ID attribute is the value sent to the arduino -->
<button id="11" class="led">Toggle Pin 11</button> <!-- button for pin 11 -->
<button id="12" class="led">Toggle Pin 12</button> <!-- button for pin 12 -->
<button id="13" class="led">Toggle Pin 13</button> <!-- button for pin 13 -->
<script src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".led").click(function(){
var p = $(this).attr('id'); // get id value (i.e. pin13, pin12, or pin11)
// send HTTP GET request to the IP address with the parameter "pin" and value "p", then execute the function
$.get("http://78.87.xx.xx:337/", {pin:p}); // execute get request
});
});
</script>
</body>
</html>
可以在每次按下按钮后使用特定参数(即HTTP / 1.1上的GET /?LED1 =在HTTP / 1.1上)向IP地址发送GET请求,但是侦听器端没有任何响声(http://78.87.xx.xx :337 /)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句