私は何かが不足しているかどうかを確認するのに役立つ人が必要です。ブートストラップモードのフォームは送信されません。モーダル(sidebar.php)用ブートストラップモーダルフォームが送信されない
私のHTMLコードをPHPファイルの
<!-- start Joel's modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">E-Logbook Entry</h4>
</div>
<div class="modal-body">
<form id="modal-form" method="post" action="notes_functions.php">
<fieldset>
<label>Log Entry</label>
<textarea rows="4" cols="50" class="form-control" name="note_content" placeholder="What have you learnt today?..."></textarea>
</form>
</div>
<div class = "modal-footer">
<button type = "button" class = "btn btn-default" data-dismiss = "modal">
Close
</button>
<input type="submit" name="submit" class="btn btn-default" id="submitnote" value="Submit" />
</div>
</div>
</div>
</div>
<!-- end Joel's modal -->
コード(notes_functions.php)フォーム
<script type="text/javascript">
var frm = $('#modal-form');
frm.submit(function (ev) {
$.ajax({
type: frm.attr('method'),
url: frm.attr('action'),
dataType: "JSON",
data: frm.serialize(),
success: function (data) {
alert('ok');
}
});
ev.preventDefault();
});
</script>
を提出するための
<?php
include_once 'database-config.php';
if (isset($_POST['submitnote'])) {
$noteContent = strip_tags($_POST['note_content']);
$sql = "INSERT INTO account_notes (note_contents) VALUES ('$noteContent')";
$dbh->exec($sql);
echo "New record created successfully";
echo "Log details = ".$note_contents;
}
?>
私のAJAXコード
エラーを見つけることができません:-(
'場合(ISSET($ _ POST [ '提出'])){'代わりにもし 'の(ISSET( $ _POST ['submitnote'])){'フォームのsubmitボタンの' name'属性は 'submitnote'ではなく' submit'です。 'name'属性は' id'ではなく 'POST'を通過しています。だから、それぞれを確認して修正してください –
私は変更を加えましたが、効果はありません。ところで、モーダルは、カレンダースクリプトから日付をクリックすることによってトリガーされます。アイデアは、日付がクリックされるとモーダルが呼び出され、ユーザはモーダルでフォームに記入してMySQLデータベースに提出することができます。 { onDayClick:function(events){$( "#myModal()}" 「 – GeekBoi