0

私の目標は、ajaxを介してカラーボックスモーダルでフォームを送信しその部分は完了しています)、送信された値の1つ(「パーセンテージ」と呼ばれます)を取得して、テーブルの値を更新することです。

以下にコードがあります(フォームなし)。私のフォーム(#Form_PlayerSave)を含むDivでリンクが開かれ、そのフォームが素晴らしいjQueryフォームプラグインを介してajax化されていることがわかります。フォームは正しく送信されています。テーブルの「パーセンテージ」部分を更新したいだけです。

1ページに25個のフォーム(テーブルの各行に1個)が必要なため、スクリプトにphpが含まれています。したがって、各$xは異なるフォームをカウントします。

だから、私は何をしますか?以下にあるものは未定義を返します、そして私はかなりの数のさまざまな解決策を試しました。

また、テーブル内のカラーボックスモーダルを開くためのリンクをもう一度クリックすると、フォームがすべて無秩序になっていない場合にフォームが通常送信するページが表示されることにも気づきました。ユーザーが自分の心のコンテンツに値を更新できるようにこれを修正する方法についてのアイデアはありますか?

$(document).ready(function(){

   function prepform(){



       $('#Form_PlayerSave<?= $x ?>').ajaxForm({
           // target identifies the element(s) to update with the server response
           target: '#customPlanDiv<?= $x; ?>',

           // success identifies the function to invoke when the server response
           // has been received; here we apply a fade-in effect to the new content
           success: function() {
                 $.fn.colorbox({html:"Custom Plan Saved", open:true});
                 var x = $('#Form_PlayerSave<?= $x ?> :percentage').fieldValue();
                 $('#custom_plan_text<?= $x ?>').val(x[0]);
           }

       });
   }

   $(".customPlan<?= $x; ?>").colorbox({inline:true, href:"#customPlanDiv<?= $x; ?>"}, prepform);

});

みんなの助けに本当に感謝しています!ありがとう*10!

4

1 に答える 1

0

わかった!

  $(document).ready(function(){

               function prepform(){

                    $('#Form_PlayerSave<?= $x ?>').ajaxForm({
                               // target identifies the element(s) to update with the server response

                               beforeSubmit:  CPshowRequest<?= $x ?>,
                               // success identifies the function to invoke when the server response
                               // has been received; here we apply a fade-in effect to the new content
                               success: CPshowResponse<?= $x ?>,
                               resetForm: true

                   });

               }

               $(".customPlan<?= $x; ?>").colorbox({inline:true, href:"#customPlanDiv<?= $x; ?>"}, prepform);

         });

            // pre-submit callback
            function CPshowRequest<?= $x ?>(formData, jqForm) {
                var x = $('#percentage<?= $x ?>').fieldValue();
                $('#custom_plan_text<?= $x ?>').html(x[0]);
                return true;
            }
            function CPshowResponse<?= $x ?>(responseText, statusText, xhr, $form)  {
                $.fn.colorbox({html:"Custom Plan Saved", open:true});
            }

なぜこれが機能するのかは私を打ち負かしますが、実際にそうです。:)

また、将来の見物人のために、送信時にdivが置き換えられないようにするには、ターゲットが元のフォームのdivを指していないことを確認してください(私の側ではダムダムダム)。

于 2010-12-11T21:31:45.690 に答える