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 を返します。