views:

47

answers:

1

Hello All right now i am using Json for passing status and message like

return Json(new { Success = true, Message = "Save successfully" });

 Project model=new Project()

Is there any way, i can send model in json also?
I am using c# and asp.net mvc

+1  A: 

Yes - it is very easy. The Json method accepts any object:

return Json(new Project());
korchev
how can i pass this object inreturn Json(new { Success = true, Message = "Save successfully" });, i had tried this like return Json(new { Success = true, Message = "Save successfully", Object = model }); but it is not accessible on my view
Pankaj
It should be. You can check with FireBug or Fiddler what is being sent over the wire. Generally speaking you should be able to serialize most of things (objects) as JSON.
korchev
yes you are right i am getting this on view. i am getting data.CheckListItem, but in form of object. i want to do like this. data = eval('(' + data + ')'); $("#remote-tab-1").html(data.CheckListItem);
Pankaj
when i am doing data = eval('(' + data + ')'); it return data object, my object inside this data object. how can i access this.
Pankaj