I am trying to save data using soap Jquery with C# WebMethod But can not save data in SQL Server please help me how can I save data using Soap jquery. I am using IDE Visual Studio 2015.
<script type="text/javascript">
function SavePersonRecord() {
var Name = $.trim($('#<%=txtName.ClientID %>').val());
var LName = $.trim($('#<%=txtlname.ClientID %>').val());
var Company = $.trim($('#<%=txtCompany.ClientID %>').val());
var Messege = "";
if (Name == '') {
Messege = "Can not Blank Name";
}
if (LName == '') {
Messege += "Can not Blank Last Name";
}
if (Company == '') {
Messege += " Company Name Can not Blank";
}
if (Messege.length == 0) {
$.ajax({
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
url: "Soap-Service.aspx/InsertPersonRecord",
data: "{'FirstName':'" + Name + "', 'LastName':'" + LName + "','Company':'" + Company + "'}",
success: function (Record) {
$('#txtName').val();
$('#txtlName').val();
$('#txtCompany').val();
if (Record.d == true) {
$('#Result').text("Your Record insert");
}
else {
$('#Result').text("Your Record Not Insert");
}
},
Error: function (textMsg) {
$('#Result').text("Error: " + Error);
}
});
}
else {
$('#Result').html('');
$('#Result').html(Messege);
}
$('#Result').fadeIn();
}
</script>
<table border="0" cellpadding="5" cellspacing="5" style="border: solid 2px Green;">
<tr>
<td colspan="2" style="background-color: red; color: white; font-weight: bold; font-size: 12pt; text-align: center; font-family: Verdana;">Enter Employee Information</td>
</tr>
<tr>
<td>First Name:
</td>
<td>
<asp:TextBox ID="txtName" runat="server" Text="" />
</td>
</tr>
<tr>
<td>Last Name:
</td>
<td>
<asp:TextBox ID="txtlname" runat="server" />
</td>
</tr>
<tr>
<td>Company
</td>
<td>
<asp:TextBox ID="txtCompany" runat="server" />
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btnInsertRecord" Text="Save" runat="server" OnClientClick="SavePersonRecord(); return false" />
</td>
</tr>
</table>
Vague question. However, do the following step:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With