1
フォームを送信した後にjQueryを使用して特定のPHP関数を呼び出そうとしていますが、それを実現するにはどうしますか?jQueryからPHP関数を呼び出す方法は?
ここに私のコードです:
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());
}
?>
すべてのヘルプは本当に理解されるであろう。
ありがとうございます。 、私は私はこの1つを解決した方法を共有しています同様の問題といくつかの助けが必要な場合があります誰にも
ユーザーをリダイレクトする場合は、window.locationを使用しますか? – Terry
あなたのヘッダーがhtmlの場合はphpでない –
直接ではありません。 JavaScriptはAjax(またはそれに提出できる '