サーバーへの ajax 呼び出しの一部であるコールバック関数があります。データがコールバックに返されると、関数は呼び出し元のフォーム タグ内にある span タグに情報をポストする必要があります。
この行が間違っていることは承知していますが、私の意図が説明されることを期待してそのままにしておきます。フォーム内から span タグを選択するための構文を見つけるためのヘルプを探しています。
$form.find("UpdateMessage").replaceWith(data.processingMessage);
-
var ajaxUpdateWaitTime = function () {
var $form = $(this);
var options = {
url: $form.attr('action'),
type: $form.attr('method'),
data: $form.serialize()
};
$.ajax(options).done(function (data) {
$form.find("UpdateMessage").replaceWith(data.processingMessage);
$form.children("UpdateMessage").effect('highlight');
});
return false;
};
これが役立つ場合のマークアップです。
<input type="button" data-ucw-updateWaitTimeButton="@facility.Id" value="Edit" />
<form method="post" action=@Url.Action("UpdateWaitTime", "Facilities") data-ucw-updateWaitTimeForm="@facility.Id" style="display:none" >
<input type="hidden" value="@facility.Id" />
<input type="text" value="0" style="width:15px" />
<input type="submit" value="Update Wait Time" />
<span class="UpdateMessage"></span>
</form>
読んでくれてありがとう。