看板 Ajax 關於我們 聯絡資訊
請問版友 我在一個網頁上要控制攝影機可以轉向 但是我在按下轉像按鈕後,整個網頁會重新刷新,視訊畫面會不見 要重新整理才會出現 我想在我按下攝影機轉像按鈕後,視訊的畫面仍然在,我要如何做 以下是我的程式碼 -----------------left.cgi---------- #!/bin/bash gpio mode 1 pwm gpio pwm-ms gpio pwmc 400 gpio pwmr 1000 gpio pwm 1 48 echo "Status: 204 No Content" echo "Content-type: text/plain" echo "" ----------------------------------- -------------index.html------------ <html> <head> <script Language="Javascript"> function set0() { document.location="cgi-bin/left.cgi"; } </script> </head> <body> <div class="stream"> <img src="http://192.168.1.19:8081"> </div> <div style="text-align:center"> <img src="/forward.jpg" id="f" onmousedown="set0()"> </body> </html> ---------------------------- 謝謝各位 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.232.238.188 ※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1437061273.A.D15.html ※ 編輯: pujols05 (36.232.238.188), 07/17/2015 00:11:22
Peruheru: 使用ajax送出請求,網頁就不會重讀了,這就是本版宗旨XD 07/17 09:51
Peruheru: https://api.jquery.com/jquery.get/ 07/17 09:52
Peruheru: 看你的寫法是直接導向到畫面往左的網頁,那就用Get 07/17 09:52
Peruheru: $.get( "cgi-bin/left.cgi", function( data ) { }); 07/17 09:54
Peruheru: <script type="javascript" src="jquery位置"></script> 07/17 09:57
Peruheru: 先去下載jquery放進網站資料夾內,然後把上面位置改掉 07/17 09:57
Peruheru: 改掉後放到<script Language="Javascript">之前 07/17 09:58
Peruheru: 再把 document.location="cgi-bin/left.cgi"; 換成四樓 07/17 09:59
Peruheru: 懶得理解ajax寫法的話這樣最快有效果 07/17 10:00
pujols05: 謝謝p大,請問我的寫法不好嗎,有更正規的寫法嗎? 07/17 14:25
pujols05: 剛接觸jquery,還在摸索。 07/17 14:25
Peruheru: document.location 指的是把本頁換到新網頁去,那當然會 07/17 14:42
Peruheru: 造成換頁,所以要用另一種方法送出你要的網頁請求 07/17 14:42
Peruheru: 也不是一定要用jQuery,只是要看到成果這樣最快 07/17 14:43
Peruheru: 我不會說你的寫法不好,只是你的寫法不合你的要求而已 07/17 14:44