如何在 html 页面中包含纤细的 api?

How to include a slim api in a html page?

我创造了一个苗条的 api。它获取数据库项目并显示它。现在如何将它包含在 html 页面中? 这是api路线

$app->get('/login/user_table(/:username)', function($username) use ($app){
                  user_table_view($username);

          });

这是我要插入 api 的 html 页面。

<div class = "view">
<-- I want the api to be displayed here -->
</div>

经过一些尝试,我找到了解决方案。 使用脚本调用 api 路由。它工作正常。

<script>
$( "#view" ).load( "http://localhost/login/user_table/001" );
</script>