Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can I save Data using Soap Jquery in SQL Server 2012? [closed]

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>

enter image description here

like image 499
Tauseef khan Avatar asked Oct 30 '22 06:10

Tauseef khan


1 Answers

Vague question. However, do the following step:

  1. Are you getting any error in browser console which breaks your javascript code?
  2. Have you captured any error in "Error:" section?
  3. If above both looks okay, have you put dubugger in your webmethod to check whether it gets hit or not?
  4. After all this,is there in any server side exception (in your webmethod)?
  5. Answer of 4) is yes, post the exception
like image 177
Tejas Vaishnav Avatar answered Nov 14 '22 03:11

Tejas Vaishnav