I cannot get another view to load after initial load of my MVC project. I am using an ajax call to run a method called SlideLayoutView within a controller called SlideView.
Here is the ajax call:
$.ajax({
url: "/SlideView/SlideLayoutView",
type: "POST",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(id),
success: function (result) {
},
});
Here is the route for it:
//slide layout view
routes.MapRoute("SlideViewPage",//Route name
"SlideView/SlideLayoutView/{id}",//URL
new { controller = "SlideView", action = "SlideLayoutView", id = UrlParameter.Optional },// paramter defaults
new[] { "ChootaAuthor.web.Controllers" });
And here is the method within the SlideViewController:
public ActionResult SlideLayoutView(int id = 0)
{
ViewBag.Message = "Slide View Page";
var model = new SlideViewModel();
model.slideID = 1;
model.slideTitle = "test";
return View("SlideLayoutView", model);
}
If I run the view itself it works fine. If I navigate to it with /SlideView/SlideLayoutView/-1 it works fine. But shouldn't it work as well if I return the View? Please help
You aren't doing anything with the AJAX result after calling the view.
success: function (result) {
NOTHING HAPPENS HERE, SO YOU CANT EXPECT ANYTHING TO HAPPEN
},