Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

WebAPI code interaction failure

$
0
0

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>


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>