0

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!

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the response! Specifically i want to go to a different view than the one being posted from. I don't want to handle the response in the original view.. I'd like to just redirect. Again.. probably doesn't make sense to post using Ajax in this case.. But maybe people are doing this?
What about redirecting to another action where i pass the model to the other action? Will this actually cause a redirect in the browser?
@billyjean: Add the redirect comment to your question by editing it. That will change the answers you get signficantly, and is actually an easy problem to solve. stackoverflow.com/search?q=ajax+redirect
OK thanks.. will do. What is the solution? I checked a few questions from the list you posted and was unable to determine the answer..
0

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.

1 Comment

Yeah no doubt.. But i am using knockoutjs and doing some complicated validation. With knockout it's super easy to post your js model with JSON. And i essentially need to go to another view entirely once i post. Maybe i should just replace part of the DOM.. but overall it will make more sense to go to a new "page".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.