I know this is probably a common and easily answered question, but I’m a nub. Here’s my situation:
I have a list of complex objects that I can send just fine using an ajax call as follows:
$j.ajax({
url: actionURL,
type: 'POST',
dataType: 'json',
data: dataToSend,
contentType: 'application/json; charset=utf-8',
success: function (response)
{
alert(response);
}
});
The MVC3 Controller action at “actionURL” gets the object and automatically deserializes it to the object I want. However, when I return an ActionResult from that controller function, nothing happens. I want to regain control in this controller function and return a “PostResults” view defined in cshtml just like I do in every other controller function, but it seems like my return is returning to JS. I am guessing the answer has something to do with routing, but as I said I’m a nub.
Any idea why the JS ajax call seems to be taking control of the flow, and how to stop this from happening? I want this JS module to just act like every other view I have!
You want to do a post-redirect. Find out more info Here.
The true purpose of ajax is to actually NOT leave the current page user is viewing, thus creating a more responsive and fast UI.