I want also call view1 and view2 methods.but it does not work.the Method "SubmitMyData" works properly and return the views for my ajax call .after run i expected the execution (for example )view2. In this example i must see view2
[System.Web.Mvc.Route("Home/SubmitMyData/")]
[System.Web.Http.HttpPost]
public ActionResult SubmitMyData([FromBody]MyParamModel mydata)
{
if (mydata.Prop1.Equals("1"))
{
view1();
return View("view1");
}
else
{
view2();
return View("view2");
}
}
here is the bodies of views methods
public ActionResult view1()
{
ViewBag.Title = "view1";
return View();
}
public ActionResult view2()
{
ViewBag.Title = "view2";
return View();
}
and here is my ajax call (if necessary to see)
$('#Buttonv').click(function () {
var myData = {Prop1: "10", Prop2: ""};
$.ajax({
type: 'POST',
data: myData,
url: '/Home/SubmitMyData',
})
.success(function (data) {
$('#lblmessage').html(data);
})
.error(function (xhr, ajaxoption, thrownError) {
$('#lblmessage').html("moshkelo" + xhr + "ajaxoption= " + ajaxoption + " throwerror=" + thrownError);
})
//return false;
});