So I am calling my action result method using this:
var url= "/Example/Controler/1/Action";
$("<form action='"+url+"'></form>").submit();
But the action Method is not called... I have also tried this
$.post(url, function (data) {});
And this works, we call the controller, but then the page doesn't refresh...
My action method looks like this:
public ActionResult DoStuff(int Id)
{
.....
return RedirectToAction("index", new { Id });
}
So I am calling my action result method using this:
var url= "/Example/Controler/1/Action";
$("<form action='"+url+"'></form>").submit();
But the action Method is not called... I have also tried this
$.post(url, function (data) {});
And this works, we call the controller, but then the page doesn't refresh...
My action method looks like this:
public ActionResult DoStuff(int Id)
{
.....
return RedirectToAction("index", new { Id });
}
Share
Improve this question
edited Mar 25, 2014 at 14:48
Greeed
asked Mar 25, 2014 at 12:55
GreeedGreeed
4192 gold badges8 silver badges29 bronze badges
3
-
Are you actually submitting data? (is the
<form>
required?) Also, is your action decorated withHttpPost
by chance? – Brad Christie Commented Mar 25, 2014 at 12:57 - In $.post() method success function, you have to update page content – 111 Commented Mar 25, 2014 at 12:58
- @ Brad Christie nope no httppost – Greeed Commented Mar 25, 2014 at 13:04
1 Answer
Reset to default 5You can use Ajax function as follows :
$.ajax({
url: "/Controler/Action",
data: { 'Id': groupId },
type: 'GET',
success: function (result) {
//do the necessary updations
},
error: function (result) {
}
});
You can also try form submission as follows :
@using (Html.BeginForm("Action", "Controller", FormMethod.GET))
{
// do your html
<input type="submit" value="save"/>
}