I'm trying to pass a jquery variable to a PHP file using Ajax Post Request but there is no response from the request (it's not working )
Request Code:-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script type="text/javascript">
function logger(btni){
$('table [type="checkbox"]').each(function(i, chk) {
if (chk.checked) {
var cusId = $('table').find(".ip").html();
$.ajax({
url: "somefile.php", // php file path
method: "POST", // send data method
data: {"total_price": cusId}, // data to send {name: value}
success: function(data){
alert(data);
} // response of ajax
});
}
});
}
</script>
button to trigger the request
<button type="button" style="font-family:Modeseven-L3n5; margin-left:1rem;"class="btn btn-warning pull-left kl" id="btni"name="btni"Onclick="logger()" ><i class="fa fa-cloud-upload"></i> Upload Miner</button>
somefile.php
<?php
$total_price = $_POST["total_price"];
echo $total_price;
?>
Error in console :
main.php:42 Uncaught TypeError: $.ajax is not a function
at HTMLInputElement.<anonymous> (main.php:42)
at Function.each (jquery-3.4.1.slim.min.js:2)
at E.fn.init.each (jquery-3.4.1.slim.min.js:2)
at logger (main.php:37)
at HTMLButtonElement.onclick (VM948 main.php:488)