I am struggling with this ajax get POST. I have tried various methods of grabbing user info and sending it to a fake server (my php file) including
serializing the form data,
adding action="reserveA.php" and method="post" to the form declaration,
and having the data in the ajax equal to the form input id.val()
I am sure I am messing up somewhere else and although I have a php page that I am referencing to, I don't have anything on the page because I don't know what to put on it.
HTML Form
<form id="thisform" action="reserveA.php" method="post">
<fieldset>
<legend>Place a Reservation</legend>
<label for="firstName">First name: </label>
<input id="firstName" type="text" placeholder="first name" autofocus="autofocus"
required="true" /><br/><br/>
ending with
<input id="submit" type="submit" value="Submit"/>
JS
$(document).ready(function() {
var submit = document.getElementById("submit");
var firstName = $("#firstName").val();
var LastName = $("#LastName").val();
var Phone = $("#Phone").val();
var Party = $("#Party").val();
var dateof = $("#dateof").val();
var Timeof = $("#Timeof").val();
submit.onclick = function(){
$.ajax({
url: "reserveA.html",
dataType: "json",
data: $("thisform").serialize(),
type: "POST",
success: function() {
console.log("oh")
alert("form submitted");
},
});
}
}
then my reserveA.php
is blank.