なぜこれが機能しないのか、または私がやりたいことを行う別の方法を教えてください。
送信をクリックするとページにフォームがあり、それを add.php に処理し、right という DIV で開くようにします。
フォームページ
<script>
$("#Submit").click(function() {
var url = "add.php"; // the script where you handle the form input.
$.ajax({
type: "POST",
url: url,
data: $("#myForm").serialize(), // serializes the form's elements.
success: function(html){ $("#right").html(html); }
});
return false; // avoid to execute the actual submit of the form.
});
</script>
</head>
<body>
<form action="add.php" method="post" enctype="multipart/form-data" id ="myForm">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name = "email"><br>
Phone: <input type="text" name = "phone"><br>
Photo: <input type="file" name="photo"><br>
<input type="submit" value="Upload">
</form>
</body>
フォームにアクションを追加して add.php に指示すると、すべて正常に動作するので、他のスクリプトは問題ありませんが、この方法で実行すると何も起こりません。 .
誰にも何か提案がありますか?