asp.net mvcショッピングカートにページがあり、クーポンを入力して他のページのコンテンツと一緒に注文の要約を表示できます。クーポンコードを検証し、エラーを報告し、jQuery ajax経由でページ上の注文概要を更新する更新ボタンを希望します。複数のdivをjQueryのajaxレスポンスから更新する
フォームと部分的なビューを作成し、jQueryでターゲットプロパティを使用することで、これを行うことができます。しかし、私は以下のような何かを行うことができます考えていた:
var options
{
success: function (responseHtml) // contains the entire form in the response
{
// extract sub-sections from responseHtml and update accordingly
// update <div id="coupon"> with coupon div from responseHtml
// update <div id="order-summary> with order summary div from responseHtml
}
}
$('#my-form').ajaxSubmit(options); // submits the entire form
ここでの利点は、私は完全なページ・リフレッシュを行うか、更新が必要な領域のすべてを含む部分のビューを作成する必要がないということです。 jQuery ajaxでこれを行う適切な方法はありますか?
これはコードの小さな宝石がある - どうもありがとうございました:] – xgstr