アイテムのリストがあり、各アイテムにボタンがあります。そのボタンをクリックすると、サーバー呼び出しが行われ、その呼び出しの後、ボタンのテキストを変更する必要があります。したがって、この関数を ajaxify 呼び出しに記述します。
$('.form').ajaxForm({
beforeSubmit: function () {
},
success: function (result) {
$('.itemHoverBox').attr('value', 'Confirmed');
},
error: function (xhr, textStatus, errorThrown) {
}
});
これはアクションボタンです:
@using (Html.BeginForm("Confirm", "Products", new { productId = @t.ProductId }, FormMethod.Post, new { @class="form"}))
{
<input style="width: 60px;" class="itemHoverBox button white" type="submit" value="Confirm" />
}
しかし、これitemHoverBox
はページ上のすべての変更であり、私がしようとしているのは、クリックしたボタンを変更することだけです。ここでスタックオーバーフローのお気に入りの質問スターをクリックしたときのように。
私のアクションメソッドは今のところ void を返します:
[HttpPost]
public void CollectTicket(int ticketId)
{
...
}