Hello, I'm using asp.net mvc with jquery. I'm trying to make a formpost and just update the ascx that making the post.
I'm making the post with following code:
$(document).ready(function() {
$('#search-form').submit(function() {
var form = $('#search-form');
var action = form.attr('action');
var serializedForm = form.serialize();
$.post(action, serializedForm, function() {
});
return false;
});
});
Then I have an action:
[HttpPost]
public ActionResult Method(FormCollection collection)
{
//code...
ViewData["post"] = "Hello world";
return View();
}
This is working fine. The code is executing, but the problems occur after return view. For example if I try to print out the "Hello world" in the view it is never updated. Could someone explain why and do anyone know about a solution?