Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Json string call for ajax call

$
0
0

Hi all,

i am trying to bind jqgrid in through the json objects.

i ll get json objects using to get this method

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]

public string GetJson()
{

dataset datasource = (Dataset)Session[tbl1];
System.Web.Script.Serialization.JavaScriptSerializer serializer = new

System.Web.Script.Serialization.JavaScriptSerializer();
List<Dictionary<string, object>> rows =
new List<Dictionary<string, object>>();
Dictionary<string, object> row = null;

foreach (DataRow dr in dsSource.Tables[0.Rows)
{
row = new Dictionary<string, object>();
foreach (DataColumn col in dsSource.Tables[0].Columns)
{
row.Add(col.ColumnName.Trim(), dr[col]);
}
rows.Add(row);
}
return serializer.Serialize(rows);

}

while i am calling ajax calling in client side 

its not showing data

<script type="text/javascript">
function LoadData() {
try {
$.ajax({
type: "POST",
url: "Default.aspx/GetJson",
data: "{}",
contentType: "application/json",
dataType: "json",
success: function (msg) {
alert(msg.d);
}
});
}
catch (err) {
alert(err.description);
}
}

</script>
<body class="no-skin" onload="LoadData()" id="service"></body>

am defined static method of getjson mean the seesion will be get error. so please give any one other way to do this one


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>