POST в php и обновление контента
Есть два файла первый test.php содержит код содержание страницы
<script>
function getposition(){
document.getElementById('msg').style.display='block';
document.getElementById('dannye').style.display='none';
var keyword = $('#keyword').val();
$.ajax({
timeout: 960000,
type: "POST",
url: "checkposition.php",
data: {keyword:keyword},
success:function(search) {
$('#instatable').html(data);
document.getElementById('msg').style.display='none';
document.getElementById('dannye').style.display='block';
}
});
}
</script>
<body style="">
<div class="container">
<div class="col">
<h1 id="navbar1">Позиция группы в поиске ВК</h1>
</div>
<div class="col">
<div class="border-bottom border-primary">
<div class="form-group">
<label for="keyword">Запрос</label>
<input type="text" class="form-control" id="keyword" value="saq">
<small class="form-text text-muted">ключевое слово или фраза</small>
</div>
<p align="right"><button class="btn btn-danger" name="submit" id="submit" onclick="getposition()">Проверить позицию</button></p>
</div>
</div>
<div id="msg" style="display:none">
<center>
<img src="https://grolik.ru/images/waiting.gif">
</center>
</div>
<?php include ('checkposition.php');?>
</tbody>
</table>
</div>
</div>
При нажатие на кнопку выполняется функция onclick="getposition()" Файл checkposition.php содержит api запрос и генерацию таблицы с результатом
<?php
$search_get = file_get_contents('https://api.vk.com/method/groups.search?q=$_POST["keyword"]&access_token=токен&sort=1&v=5.131&count=50');
$search = json_decode($search_get, true);
$counter = 1
?>
<div id="dannye" class="col-lg-14" style="display: block;">
<legend id="inform"></legend>
<table id="tblExport" class="table table-striped">
<thead>
<tr>
<th>№</th>
<th>Аватар</th>
<th>Название</th>
<th>Короткая ссылка</th>
</tr>
</thead>
<tbody>
<?php
foreach ($search['response']['items'] as $item) {
echo '<tr>';
echo "<td></td>";
echo '<td><img class="photo_group_200" src="'.$item['photo_50'].'"></td>';
echo "<td>{$item['name']}</td>";
echo "<td>{$item['screen_name']}</td>";
echo '</tr>';
}
?>
</tbody>
</table>
</div>
Как сделать что бы после нажатия функция с пост запросом обработалась и отобразила таблицу в test.php