私の行動には次のものがあります
[AjaxException]
public ActionResult DoSomething(sring someParam1, string someParam2) {
//do whatever you need to do here, db etc
return new EmptyResult();
}
私のhtmlで
<form id="search-frm" name="search-frm" action="@Url.Action("DoSomething", "MyActions")" method="post" >
<input type="button" id="search-btn" value="search" class="btn" onclick="DoSomething();return false;" />
<input type="text" name="param1" id="param1" />
<input type="text" name="param2" id="param2" />
</form>
私のJSで
function DoSomething() {
$("#search-frm").submit();
return false;
}
ボタンをクリックすると、コントローラーのアクションDoSomething
が実行された後、にリダイレクトされMyActions/DoSomething
ます。jqueryを使用せずにそれを持たない方法はあり$.ajax
ますか?私は単に何かをする必要があり、既存のページから離れることはありません。
ありがとうございました。