我想保存使用肥皂Jquery的與C#的WebMethod數據,但無法保存數據SQL服務器請幫助我,我怎麼能節省使用香皂的jQuery數據。我使用IDE Visual Studio 2015。如何在SQL Server 2012中使用Soap Jquery保存數據?
<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>
請問這個問題得到upvoted?請描述你的努力和具體問題。 –
@RomanoZumbé正是我想知道的,一些代碼(你試過的任何代碼)也會有幫助。 –