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 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作