duanmianhong4893 2014-08-22 22:17
浏览 56
已采纳

Php按钮调用php程序

I am totally new. So this might seem basic. But I tried various methods and had no good results.

I am trying to build a browser based remote control to my sonos. I have various php programs to play, volume up, etc

How do I display multiple buttons that when pressed calls up the related php programs to control the sonos. Ideally the displayed page should stay at the same page showing the buttons.

Please guide me on the php/html code

Thanks

  • 写回答

2条回答 默认 最新

  • donglian1523 2014-08-28 22:17
    关注

    i followed this example

    http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first

    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function loadXMLDoc()
    {
    var xmlhttp;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","ajax_info.txt",true);
    xmlhttp.send();
    }
    </script>
    </head>
    <body>
    
    <div id="myDiv"><h2>Let AJAX change this text</h2></div>
    <button type="button" onclick="loadXMLDoc()">Change Content</button>
    
    </body>
    </html>
    

    on this line " xmlhttp.open("GET","ajax_info.txt",true); "

    i changed out the *.txt for my *.php program that i am calling.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料