billy jean
billy jean

Reputation: 1419

Post with jquery and return/redirect different view with model

i have a form which is posted using jquery,

i could use regular form submission i suppose.. but is there some way to have my result push a new view and model based on the post results? Someone suggested what i want to do is redirect.

my controller returns:

return View("User/Default", model);

but because i am posting with AJAX this is not working. thanks!

Upvotes: 0

Views: 533

Answers (2)

Robin van der Knaap
Robin van der Knaap

Reputation: 4120

BC's answer probably fits your needs. If you're seeking true awesomeness ;) you could let your controller return a json result and use jquery templates to render the views clientside.

Upvotes: 0

BC.
BC.

Reputation: 24918

By calling View() You're returning an entire document (ViewResult), which can be used by your ajax success callback, but maybe you're looking for PartialViewResult, which would be an html fragment and faster/easier to work with.

Upvotes: 1

Related Questions