I have a view with a submit form: when I click on it, the jquery / ajax function is called. This function should encode the view model, call the controller action and show the returned view. Now this is my function:
<script type="text/javascript"> function Analyze() { var urlact = '@Url.Action("Analysis")'; var model = '@Html.Raw(Json.Encode(Model))'; $.ajax({ data: model, type: "POST", url: urlact, dataType: "json", contentType: "application/json; charset=utf-8", success: function (data) { </script>
And the Analysis action is kind of
public ViewResult Analysis(IEnumerable<Azienda> aziende) { Debug.WriteLine(aziende.Count()); return View(aziende); }
The return of the species! How can I show that View on success: function (data)? I tried changing the dataType to html and calling alert (data) for success, but I had problems with the encoded model, I tried to comment out the contentType line, but the same problem with the model encoding.
Does anyone know how to do this? The js / query / ajax workaround is fine too.
Thanks everyone!
source share