I'm trying to figure out a way to pass the entire class from my View to a Controller with Javascript/AJAX.
I know the following Ajax code can be used to pass just the ID but can I pass the entire model ?
@model User
$.ajax(
{
type: "POST",
url: "\User\",
data: @model.id,
success:
reloadPage()
});
I saw the following solution while searching: Is there a way to pass a "C#" object to a controller via AJAX?
Can I simply do this instead ? :
@model User
$.ajax(
{
type: "POST",
url: "\User\",
data: @model,
success:
reloadPage()
});
Will this work ? How safe ? What's the best way ?