1

ASP.NET MVC アプリに uploadify を使用して .csv ファイルをアップロードしています。コントローラー アクションから、次のような値をいくつか含む JSON を返します。

return Json(new { success = false, message = result.Message });

以下は、アップロードのコードです。

$("#email").uploadify(
                    {
                    'uploader': '/js/component/uploadify/uploadify.swf',
                    'script': '/email/UploadEmail',
                    'cancelImg': '/js/component/uploadify/cancel.png',
                    'fileExt': '*.csv',
                    'fileDesc': '*.csv',
                    'auto': true,
                    'multi': false,
                    'buttonText': 'Upload...',

                        'onComplete': function (event, queueID, fileObj, response, data)
                            {

                                alert(jQuery.parseJSON(response));
                                alert(jQuery.parseJSON(response.message));
                                var filename = fileObj.name;
                                $('#emailSuppressionFile').append('<input id="' + queueID + '" type="hidden" name="files[' + queueID + ']" value="' + filename + '" />');                                   
}                                
                    });

コントローラーアクションから返された「メッセージ」を読み取ろうとしていますが、方法がわかりません。上記のアラートを参照してください。最初のアラートは [object Object] を返し、2 番目のアラートは null を返します。

4

2 に答える 2

3

このようにしてみてください:

onComplete: function(event, queueID, fileObj, response, data) {
    var json = jQuery.parseJSON(response);
    alert(json.message);
},

また、イベント名を引用符で囲まないでください。

于 2012-10-02T15:58:53.317 に答える