Bineesh  Viswanath

Bineesh Viswanath

  • NA
  • 1k
  • 775.4k

Data Insertion into Database using JQuery

Sep 6 2013 2:44 AM
Sir, I am doing a data insertion function in Jquery.

in this program, getting either output nor error.

so please check whether function ClassAdd() has any error.

Also note that I am getting result in another way( see in the last part of this post)

.aspx code:-

<script type="text/javascript" language="javascript">

    function ClassAdd()
     {

         alert('Done');
         var class = $("#txtClassName").val();
         var Seats = $("#txtSeats").val();
         $.ajax({type:"POST",async:false, url:"WebService.asmx/ClassAdd", data:"{a:' "+ class +" ',b:' "+ Seats +" '}",
         contentType:"Application/json:charset=utf-8",
         dataType:"json";
         success:function(response));
    }


 

</script>
      <div>
   <table>
   <tr>
   <td >
       <asp:Label ID="Label1" runat="server" Text="ClassName"></asp:Label>
   </td>
   <td>
       <asp:TextBox ID="txtClassName" runat="server"></asp:TextBox>
      
   </td>
  
   </tr>
   <tr>
   <td >
       <asp:Label ID="Label2" runat="server" Text="Seats"></asp:Label>
   </td>
   <td>
       <asp:TextBox ID="txtSeats" runat="server"></asp:TextBox>
   </td>
   </tr>
   <tr>
   <td >
       <asp:Button ID="btnSave" runat="server" OnClientClick="ClassAdd()" Text="Save" Width="62px"
            />
   </td>
   <td>
       <asp:Button ID="btnClear"

webService.cs:-

  [WebMethod]
    public void ClassAdd(string a, int b)
    {
        ClassSP spClass = new ClassSP();
        ClassInfo InfoClass = new ClassInfo();
        InfoClass.className = a;
        InfoClass.Seats = b;
        spClass.classAdd(InfoClass);

    }

I am getting result and data is being inserted to the database with the help of WebService.

I put break point in the ClassAdd() function in WebService.cs file. And here the happenings after i press F10:-



When click on ClassAdd:-







And I am getting this when I press Invoke button:-




And then I am getting the Message:-"Saved Sucessfully"


The window below not giving me the output:-


So please give me the cause to these functions.



Answers (4)