I am having problem with running the below code. The form is not interacting with Javascript.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="CRMWebpAPI.index" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="Scripts/jquery-3.2.1.js"></script>
<head runat="server">
<title></title>
<script type="text/javascript">
$(document).ready(function () {
$("#LeadForm").submit(function (event) {
$.ajax({
type: "POST",
url: "localhost/.../CRMLead",
data: $("#LeadForm").serialize(),
dataType: 'json',
success: function (response) {
alert(response);
$('#LeadForm').each(function () {
this.reset(); //Reset each field
});
},
error: function (request, textStatus, errorThrown) {
alert(request.responseText + " " +
textStatus + " " + errorThrown);
}
});
event.preventDefault();
});
});
</script>
</head>
<body>
<form id="LeadForm">
<label for="FirstName">First Name</label>
<input type="text" id="FirstName" name="FirstName" />
<br />
<label for="LastName">Last Name</label>
<input type="text" id="LastName" name="LastName" />
<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>