Web Service PART-5 ( Call Web Service using JQuery)

//============JavaScript===============
function GetBreakFee() {

    var installment = $("#Id").val();
   $.ajax({
        url: 'http://localhost:46944/webService/Test.asmx/GetData',
        method: 'post',
        dataType: 'json',
        data: { Id: Id},
        success: function (res) {
            //alert("Success : " + res);
               $(res).each(function (index, item) {
                var row = "<tr><td>" + res[index].name + "</td>";
                   row += "<td>" + res[index].name+ "</td>";
                $('#tblData').append(row);
            });
        }, //Success
        error: function (ex) {
            alert("Error : " + ex)
        }
    });   //----ajax method end
}

//==================Web Service==============================
using System.Web.Script.Serialization;

 [WebMethod(EnableSession = true)]
public void GetBreakFee(string Id)
    {
        JavaScriptSerializer js = new JavaScriptSerializer();//System.Web.Script.Serialization;

        string sql = "select * From Detail ";

        dt = GetData(sql);

        List<Detail> d= new List<Detail>();

        foreach (DataRow row in dt.Rows)
        {
            Detail obj = new Detail();

            obj.Id = row["id"].ToString();
            obj.name = row["name"].ToString();
            d.Add(obj);
        }
        Context.Response.Write(js.Serialize(liFeeDetail));
    }//Session Condition Closed
//=====================================================
class Detail 
{
    public string Id{ get; set; }
    public string name{ get; set; }
  }

No comments:

Post a Comment

IIS deployment support details

  Node JS - IIS deployment support details node: http://go.microsoft.com/?linkid=9784334 IISNode: https://github.com/azure/iisnode/releases/...