0

3つの非表示フィールド、1つの選択ボックス、10個のチェックボックスと送信ボタンを含むdivを持つhtmlフォームを持つjspページがあります。フォームのアクション プロパティで、このフォームに設定されているアクション ページがありません。フォームは ajax を使用して送信されます。フォームは、選択ボックスの変更イベントでサーブレット A に送信されるか、送信ボタンのクリック イベントでサーブレット B に送信されます。

選択ボックスの値が選択されるたびに、ajax を使用してフォームが送信され、チェックボックスに関連付けられたユーザー名のリストを含む ajax の応答が、ページを更新せずに div でレンダリングされます。この部分は正常に動作します。

送信ボタンがクリックされると、フォームは ajax を使用して送信され、チェックボックスが選択されている場合は、チェックボックスの値がセッションに保存されます。問題はここにあります。Jsp ページが初めてレンダリングされ、いくつかのチェックボックスを選択して送信ボタンをクリックすると、上記の機能が正常に動作します。しかし、jspページがレンダリングされ、選択ボックスオプションが選択され、そのajax応答がチェックボックスを含むレンダリングされ、ここでいくつかのチェックボックスを選択して送信ボタンをクリックすると、サーブレットBIで非表示フィールドの値のみを取得し、ボックスを選択して値のチェックボックスがサーブレット B に受信されません。

この問題の背後にある理由と、これに対する解決策を専門家に尋ねたいと思います。

以下は、送信ボタンをクリックして実行されるjqueryコードです。

$("#idbtnsubmituser").click(function(){
    //alert("this is test1");

    //get the form data and then serialize that
    dataString = $("#userlistrequestform").serialize();  
    /*
    As per my understanding the above code line is not getting the selected     checkboxes value. i.e. the serialize function can not 
detect the check boxes rendered by ajax response on event of select box change event.
    */
    $.ajax({
     type: "POST",
     url: "CutUser",
     data: dataString,
     //dataType: "json",

    //if received a response from the server
    success: function( data, textStatus, jqXHR) {
        $("#idmoveuserdiv").html(data);
    },

    //If there was no resonse from the server
    error: function(jqXHR, textStatus, errorThrown){
         console.log("Something really bad happened " + textStatus);
          $("#ajaxuserListResponse").html(jqXHR.responseText);
    },

    //capture the request before it was sent to server
    beforeSend: function(jqXHR, settings){
        $('#userlistpageselect').attr("disabled", true);
    },

    //this is called after the response or error functions are finsihed
    //so that we can take some action
    complete: function(jqXHR, textStatus){
        //enable the button 
        $('#userlistpageselect').attr("disabled", false);
        $('.checkuser').attr("checked",false);
    }
});
});

この問題で友達を案内してください。

ありがとうございます!

4

0 に答える 0