How does the Button of Html trigger the method of php?

how does the Button of Html trigger the method of php?

<?php

// First, include Requests
include("../library/Requests.php");

// Next, make sure Requests can load internal classes
Requests::register_autoloader();

function get_data(){
    // Now let"s make a request!
    $request = Requests::post("http://103.200.32.76:8000/api/groups/list/", array(), null);

// Check what we received
    var_dump($request);
}

?>

<button @on="get_data()"></button>

this triggers the js method. How can I get it to trigger the PHP method?

May.07,2021

impossible! Only if the php framework you use supports this grammatical candy. The basic principle of
client calling server method is:
client triggers the client's js method, in which ajax is used to initiate a request to the server-the parameter is the name or execution parameter of the server method you want to execute, and the server parses the request and executes the corresponding method.
this set of things is either written by yourself or supported by the framework.


Why don't you just write js, and use js to trigger PHP?

Menu