Here is the method I’m calling:
public Bear GetBear(int bearId)
{
MyEntities be = new MyEntities ();
Location bear = (from b in be.Bears
where b.id == bearId
select b).First();
return bear;
}
Here is how I call it:
$.ajax({ url: "Bear/GetBear", data: { bearId: 2}, success: function (bear) { alert(bear.id) } })
But, the text in the alerted dialog box is undefined. And when I’m moving through GetBear with breakpoint, the returned bear HAS id. What am I doing wrong?
Shouldn’t you convert the data into json/xml/text/dataType (http://api.jquery.com/jQuery.ajax) before sending it back?