<form id="searchForm" method="post">
<div class="input-group">
<input type="text" class="form-control" name = "form-control" placeholder="Поиск..." aria-label="Поиск...">
<span class="input-group-btn">
<button class="btn btn-secondary" type="submit">Найти</button>
</span>
</div>
<div class="form-check mt-2">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name = "form-check-input">
Не учитывать регистр
</label>
</div>
</form>
<hr/>
<div id="searchResult"></div>
<?php
echo $_POST['word'];
?>
$(function(){
$("#searchForm").submit(function (event) {
submitForm();
});
function submitForm(){
var form = $("#searchForm");
var word = form.find("input[name=form-control]").val();
var register = form.find("input[name=form-check-input").val();
$.ajax({
type:"POST",
dataType: "json",
url: "1.php",
data:{
"word": word,
"register": register
},
success:function(data) {
if (data.success){
$('#searchResult').html(data);
} else {
alert("Ошибка");
}
}
});
}
});