フォームをリロードしないでフォームを送信しようとしていますが、現在は苦労しています。リロードからのフォーム提出の防止
現在の設定で送信ボタンをクリックしても何も起こっていません。 onsubmit="return validateForm()"
を削除すると、データは保存されますが、ページがリロードされます。
フォームHTML
<form id="predictionform-1" action="" method="post" onsubmit="return validateForm()"><p style="text-align: center;"><input type="hidden" id="_footballpool_wpnonce" name="_footballpool_wpnonce" value="f12119edf4"><input type="hidden" name="_wp_http_referer" value="/play/"><input type="hidden" name="_fp_form_id" value="1"></p><table id="matchinfo-1" class="matchinfo input"><tbody><tr><td class="matchtype" colspan="11">All</td></tr><tr><td class="matchdate" colspan="11">Dec 13, 2016</td></tr><tr id="match-5-1" class="match open" title="match 5">
</tr>
<tr><td class="score" style="width: 48%; text-align: center;"><input type="text" maxlength="3" name="_home_5" value="3" class="prediction"></td>
<td style="width: 4%; text-align: center;"></td>
<td class="score" style="width: 48%; text-align: center;"><input type="text" maxlength="3" name="_away_5" value="1" class="prediction"></td>
<td title="score" class="numeric"><span class="no-score"></span></td>
</tr></tbody></table><div class="buttonblock button-matches form-1"><input type="submit" name="_submit" value="Save"></div><input type="hidden" id="_action_1" name="_fp_action" value="update"></form>
はJavaScript
<script type="text/javascript">
function validateForm()
{
return false;
}
すべてのヘルプははるかに高く評価されます。
おかげ
どのコンソールエラー? – Utkanos
これにはajaxを使用する必要があります。 googleで検索する – Dekel
フォームを 'document.getElementById( 'predictionform-1')でバインドします。onsubmit = function(event){event.preventDefault(); } 'またはそれ以上の場合でも[addEventListener](https://developer.mozilla.org/en/US/docs/Web/API/EventTarget/addEventListener)を使用してください – GillesC