Converting Jquery Ajax Call To Vanilla Javascript - Cannot Post /public/ Error
So this is a slight follow up to a question I had yesterday (Update HTML input value in node.js without changing pages), I'm attempting to submit a HTML form, send an ajax request
Solution 1:
all looks good except the two lines:
var num1 = getElementById("numa");
var num2 = getElementById("numb");
it should be like this
var num1 = document.getElementById("numa");
var num2 = document.getElementById("numb");
Note: updated html code (added onsubmit in form and removed from button)
<form id="add" method="post" onsubmit="return add()">
Number 1:
<input type="number"id="numa" name="numa" step="any"/><br>
Number 2:
<input type="number"id="numb" name="numb" step="any"/><br>
<input type="number"id="answer" name="answer"readonly/>
<input type="submit" value="Submit"/>
</form>
Post a Comment for "Converting Jquery Ajax Call To Vanilla Javascript - Cannot Post /public/ Error"