I am using uploadify to upload .csv files on my ASP.NET MVC app. From the controller action I return a JSON with a couple of values like this:
return Json(new { success = false, message = result.Message });
The following is the uploadify code:
$("#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 + '" />');
}
});
I am trying to read the "message" that I returned from the controller action but can't figure out how. Please see the alerts above.The first alert returns: [object Object] and the second return null.
Try like this:
onComplete: function(event, queueID, fileObj, response, data) {
var json = jQuery.parseJSON(response);
alert(json.message);
},
Also don't put quotes around the event name.