0

class='chkspec' のチェックボックスがいくつかあり、クリックしたチェックボックスの ID 値を xxx.php ファイルに渡します。私の問題は次のとおりです。

1) "specificitem=this.id" で試した ID の渡し方がわからないが、正しい方法かどうかわからない

2) 次のエラーが表示されます: 未定義の変数: 特定のアイテム。これは、specificitem="hello"; を実行した場合にも発生します。

コードは以下です。

if ($('.chkspec').is(":checked")) {

        xmlHttp.open('POST', "xxx.php", true);    
        xmlHttp.onreadystatechange = function() 
        {
            if(xmlHttp.readyState == 4) 
            { 
                if (xmlHttp.status == 200) 
                {

                    data: {specificitem : this.id } 

                }


            }
        };

返信ありがとうございます。

4

1 に答える 1

0

私は純粋なJSを本当に知りません。私はJQueryの男です。私はこのようにします:

if ($('.chkspec').is(":checked")) {
    var data;
    $.ajax({
        url:"xxx.php",
        data:$('.chkspec').attr('id'),
        method:'post', 
        success:function(result){
           ;//
        }
    });
}

データがどこにもないため、このエラーが発生すると思います。

于 2013-07-18T16:55:01.573 に答える