0

私はバックエンドでperlモジュールとcgiスクリプトを使用し、フロントエンドでprototypejsを使用しています。私は基本的にajaxを利用して、サーバー上で実行されているcgiスクリプトを呼び出し、別のファイルを呼び出して、送信されたデータをoracledb内に配置します。

fronendスクリプトは次のとおりです。

new Ajax.Request ('ajax-sr-update.cgi', {
    method: 'post',
    asynchronous: 'false',
    parameters: { 
        incident_id: incident_id,
        serial_number: $F('serial_number'),
        cmd: 'Add Serial'
    },
    onSuccess: function(transport) {
    var json = transport.responseJSON();
    if (json) {
        if (json.error_message) {
            //display error message
            } 
        else if (json.incident_id) {            
            //append the output in an alredy displated table
            var new_row = '<tr id="alt-row-'+json.line_number+'">';
                new_row += '<td id="serial_number-'+json.incident_id+'" style="border-left: solid 1px #eeeeee;">'+json.serial_number+'</td>';
                new_row += '<td id="product_number-'+json.incident_id+'">'+json.product_number+'</td>';
                new_row += '<td id="transaction_type-'+json.incident_id+'">'+json.transaction_type+'</td>';
                new_row += '<td id="failure_analysis_flag-'+json.incident_id+'">'+json.failure_analysis_flag+'</td>';
                new_row += '</tr>';
                Element.replace('add-loading-row', new_row);
            } else {
                //display a general error
            }
        } else {
            //display general message
        }

    },
    onFailure: function(data) {
        //display general error message
    }
});

私が直面している問題は、テーブルが更新されたときにすべてのjsonの戻り値が未定義として表示されることですが、console.log(json.line_number)を使用すると、元の値を確認できます。過去4時間このことに取り組んでいて、私の心を失いました!!。

私がチェックしたこと:

  1. 値はデータベースから適切に取得されています。エラーログに生成しました。

  2. 生成される値の数も必要な値と同じです

  3. 私がjsonリターンを受け取ったとき、それはまさに必要なものです。

4

1 に答える 1

1

console.log(new_row)を試してみますか?それはあなたが欠けている何かをあなたに示すかもしれません。

于 2012-09-11T04:32:30.967 に答える