How to call a php script/function on a html button click

后端 未结 7 1994
南旧
南旧 2020-11-27 19:20

Before someone has a go at me or marks this down, I have looked all over the internet to find out how to do this (including the same question on stackoverflow). I\'m new, an

相关标签:
7条回答
  • 2020-11-27 20:03

    Use jQuery.In the HTML page -

    <button type="button">Click Me</button>
    
    <script>
    $(document).ready(function() {
    $("button").click(function(){
      $.ajax({
        url:"php_page.php", //the page containing php script
        type: "POST", //request type
        success:function(result){
        alert(result);
        }
      });
    });
    })
    </script>
    

    Php page -

    echo "Hello";
    
    0 讨论(0)
提交回复
热议问题