Hi everyone, I am following this link to build a Client side repeater.
According to the above link to retrive the value from a Json key-value pair we can use result[i].property,for example
for (var post in msg)
{
var x= msg[post].Date;
alert(x);
}
Here x
returns the date from Json string. When I am trying to use the same with my data, it always returns as undefined
. I tried to pop up an alert(msg.d)
that shows a nice Json string with all my data. But when I try msg[post].Date(property name)
it's always returning undefined
.
Please help..
Thanks in advance.
Update:
From the backend I am returning a generic list and then converting it into Json using the following code.
public static string ConvertToJSON(this object obj) {
DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());
MemoryStream ms = new MemoryStream();
serializer.WriteObject(ms, obj);
string jsonobj = Encoding.Default.GetString(ms.ToArray());
ms.Dispose();
return jsonobj;
}
then I am appending the returned Json to a stringbuilder and returning it to the Jquery ajax method.The returned Json looks like a string , not an object and hence I am unable to get any value from Json key value pair..