Php 如何在每次使用新标记搜索时创建和添加新表,而不重新加载侧边?

Php 如何在每次使用新标记搜索时创建和添加新表,而不重新加载侧边?,php,html,datatables,Php,Html,Datatables,我的html包括一个搜索按钮,该按钮将一个标记发布到一个API,该API返回我在表格中使用的信息:aktie.php。我确信我应该使用一些ajax、java、jQuery或w.e。但我不知道如何做到这一点。希望你们有解决办法 <?php include ('./stock_table.php'); ?> <form class="form-inline my-2 my-lg-0" method="post">

我的html包括一个搜索按钮,该按钮将一个标记发布到一个API,该API返回我在表格中使用的信息:aktie.php。我确信我应该使用一些ajax、java、jQuery或w.e。但我不知道如何做到这一点。希望你们有解决办法

<?php
include ('./stock_table.php');
?>

<form class="form-inline my-2 my-lg-0" method="post">
            <input class="form-control mr-sm-2" type="text" placeholder="Søg" 
action="./baseconfig.php" name="post_tag">
            <button class="btn btn-outline-success my-2 my-sm-0" type="submit" 
name="post_search">Søg</button>
        </form>
    </div>
</nav>    

<div class="d-flex align-items-start mt-5">
    <div class="container-xxl mt-2 d-flex flex-column bd-highlight mb-5" style="overflow-x:auto;">
        <?php
            echo build_table($data);
        ?>
    </div>
我在一个php文件中构建我的表:stock_table.php

<?php
include('baseconfig.php');

function build_table($data, 
$subheadlines4){
// start table
$html = '<div class="container">';  
$html .= '<table class="table table-responsive" style="overflow-x:auto;">';

$html .= '<thead class="thead-dark">';
$html .= '<tr>';
$html .= '<th colspan="10" class="text-center"">';
foreach($data[1] as $key=>$value) {
    $html .= htmlspecialchars($value) . " ";
}

// finish table and return it
$html .= '</table>';
$html .= '</div>';
return $html;
};
?>


你必须搜索AJAX。是的,我想是的,但我已经尝试了好几次,但都失败了。所以我希望你们能把我踢向正确的方向:)我使用AJAX得到的唯一结果是覆盖旧表并添加具有相同结果的新表请注意,
action
属性与
input
标记无关。这是一个
表单
标记属性。好的,谢谢您的更新:)
<?php
include('baseconfig.php');

function build_table($data, 
$subheadlines4){
// start table
$html = '<div class="container">';  
$html .= '<table class="table table-responsive" style="overflow-x:auto;">';

$html .= '<thead class="thead-dark">';
$html .= '<tr>';
$html .= '<th colspan="10" class="text-center"">';
foreach($data[1] as $key=>$value) {
    $html .= htmlspecialchars($value) . " ";
}

// finish table and return it
$html .= '</table>';
$html .= '</div>';
return $html;
};
?>