Hello Everyone,
I'm stuck with a problem for few days now, I can really use some help.
I'm trying to pass some data which in form of complex JSON object from a C# method to the WebPage in Jquery, here is my method in C#
[WebMethod]
public static string getAllDealsInfo()
{
SqlDataAdapter adp = new SqlDataAdapter("select top 2 de.[Deal Id], de.Merchant,de.Title, de.ImageSmall from dealdatabase de where [Deal Id] < 84520 order by [Deal Id] desc ", connection);
DataTable dt = new DataTable();
adp.Fill(dt);
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row = null;
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary<string, object>();
foreach (DataColumn col in dt.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
var serializer = new JavaScriptSerializer();
string json = serializer.Serialize(rows);
return json;
}
and here is my Call to method from Jquery side
$.ajax({
type: "POST",
url: "Default.aspx/getAllDealsInfo",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (_ObjDeals) {
var tableData = $.parseJSON(_ObjDeals.d);
alert(tableData[rows][row]);
},
error: function (x, e) {
alert("The call to the serve Failed ");
}
});
My Ajax call is successful and i have all the data in "tableData", and here starts the land where I need your help I don't know how to extract all the data.
Thanks.