Js tarafı
<script src=https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js></script>
<script>
$(document).ready(function() {
$("#veriGonder").click(function (){
var kilo = $("input[name=kilo]").val();
$.ajax({
url: "hesapla.php?mode=insert",
type: "POST",
data: {'kilo':kilo},
dataType: "json",
success: function(result) {
$(".alert").show();
$("#birinci").html(result["islem1"]);
$("#ikinci").html(result["islem2"]);
}
});
});
})
</script>
Php tarafı
<?php
switch ($_GET['mode']) {
case 'insert':
if ($_POST) {
$data["islem1"] = 1 + 1;
$data["islem2"] = 2 + 2;
echo json_encode($data);
}
break;
}
Çok teşekkür ederim! İşe Yaradı!