I am calling the following C# method:
[WebMethod(true)]
public static List<ReadUserStructure> LoadFriends()
{
List<ReadUserStructure> returner = Friend.ReadAllFriends();
return returner;
}
With the following jQuery:
$.ajax({
type: "POST",
url: "Main.aspx/LoadFriends",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) { alert(msg.Count.toString()); }
});
I have a break point on the C# method and it hits it. stepping through the method the function works fine and, in my user, creates a list with a count of 2. But this list if not getting returned to the client. Any ideas?
The problem is the list won't have a Count property in javascript. Instead, look for msg.length
Put a debugger before alert, debug in firebug or IE or Visual Studio. Check if you are receiving the object msg. If yes use msg.Length instead of msg.Count, else add error handler, and check error.
success: function (msg) {
debugger;
alert(msg.Length.toString());
},
error: function (data) {
}
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With