I know there are some people who asked same question and get answered. I already looked ino all of them, still I couldn't solve my issue. I am having a jquery snipet which send value to a handler and the handler process the value from JS and returns data as JSON data. JSON data has two sets of records( two rows from database) which need to be catch through getJSON and process that. JSON data will look like
[{"Name":"P1","Description":"pd1",Value":"S1Test1"},{"Name":"P1","Description":"pd1","Value":"L1Test1"}]
My JS is
$(document).ready(function () {
$.getJSON('ProfileHandler.ashx', { 'ProfileName': 'P1' }, function (data) {
alert(data.Name);
});
});
and my handler code is
string ProfileName = context.Request["ProfileName"];
GetProfileDataService GetProfileDataService = new BokingEngine.MasterDataService.GetProfileDataService();
IEnumerable<ProfileData> ProfileDetails = GetProfileDataService.GetList(new ProfileSearchCriteria { Name = ProfileName });
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
string serProfileDetails = javaScriptSerializer.Serialize(ProfileDetails);
context.Response.ContentType = "text/json";
context.Response.Write(serProfileDetails);
What is the approach error here?