I'm trying to call a specific php function using jQuery after my form is submitted, is there anyway to achieve that?
Here's my code:
HTML
<form id="frmAgregar" method="post">
<input id="txtcant" class="centrado" type="number" value="1" required>
<input class="btnSubmit btnResize" type="submit" value="Agregar +">
</form>
jQuery
$("#frmAgregar").submit(function() {
if ($("#txtcant").val() < 1 || $("#txtcant").val() == "") {
return false;
} else {
var popup = document.getElementById("popupAgregado");
popup.setAttribute("style", "display: block;");
popup.setAttribute("class", "popupAgregado");
setTimeout(function () {popup.style.display='none'}, 1700);
//HERE'S WHERE I NEED TO CALL THE PHP FUNCTION
}
});
PHP
<?php
function insertarDato() {
$cant = $_POST["txtcant"];
$query_insertarcontacto = mysql_query("INSERT INTO pedidotemp(cant) VALUES('$cant')", $cnbddelicomi) or die(mysql_error());
}
?>
Any help will be really appreciated.
Thank you in advanced.