Uploadify - 如何捕获新创建的scriptdata ID?

时间:2012-04-14 09:39:50

标签: asp.net-mvc jquery-plugins

我现在已经解决了这个问题,下面是解决方案: 没问题了。我只是写这个来验证我的文本。

<script type="text/javascript">

    /***************************************************/
    /* THIS VARIABLE IS USED TO TRANSPORT THE NEW ID. */
    var assignmentId;
    /***************************************************/

    $("#btnSave").click
    (
        function () {
            var inputData = $("form").serialize();
            var url = $("form").attr("action");
            $.post(url, inputData, function (data) {

    /********************************************************/ 
    /* NOW UPLOADIFY GETS THE NEW ID!! */ 
    assignmentId = data.AssignmentID; 
    alert(assignmentId.toString()); 
    $('#fileuploader').uploadifySettings("scriptData", { 'currentValue': assignmentId }); 
    /********************************************************/

                $('#fileuploader').uploadifyUpload();
            });
        }
    );


    $("#fileuploader").uploadify({
        'uploader': '@Url.Content("/Scripts/uploadify/uploadify.swf")',
        'cancelImg': '/Scripts/uploadify/cancel.png',
        'buttonText': 'Browse For File',
        'script': '@Url.Action("Upload")',
        'folder': '/uploads',
        'scriptData': { 'currentValue': assignmentId },
        'onAllComplete': function (event, data) { window.location = "/Assignment/" + assignmentId; },
        'onError': function (a, b, c, d) {
        },
        'onSelectOnce': function (event, data) { noFilesToUpload = false; },
        'fileDesc': 'Media Files',
        'fileExt': '*.jpg;*.jpeg;',
        'sizeLimit': 27000000,
        'multi': false,
        'auto': false
    });

</script>

谢谢! 我现在已经解决了这个问题,下面是解决方案: 没问题了。我只是写这个来验证我的文本。

1 个答案:

答案 0 :(得分:0)

<script type="text/javascript"> 

    /***************************************************/ 
    /* THIS VARIABLE IS USED TO TRANSPORT THE NEW ID. */ 
    var assignmentId; 
    /***************************************************/ 

    $("#btnSave").click 
    ( 
        function () { 
            var inputData = $("form").serialize(); 
            var url = $("form").attr("action"); 
            $.post(url, inputData, function (data) { 

    /********************************************************/  
    /* NOW UPLOADIFY GETS THE NEW ID!! */  
    assignmentId = data.AssignmentID;  
    alert(assignmentId.toString());  
    $('#fileuploader').uploadifySettings("scriptData", { 'currentValue': assignmentId });  
    /********************************************************/ 

                $('#fileuploader').uploadifyUpload(); 
            }); 
        } 
    ); 


    $("#fileuploader").uploadify({ 
        'uploader': '@Url.Content("/Scripts/uploadify/uploadify.swf")', 
        'cancelImg': '/Scripts/uploadify/cancel.png', 
        'buttonText': 'Browse For File', 
        'script': '@Url.Action("Upload")', 
        'folder': '/uploads', 
        'scriptData': { 'currentValue': assignmentId }, 
        'onAllComplete': function (event, data) { window.location = "/Assignment/" + assignmentId; }, 
        'onError': function (a, b, c, d) { 
        }, 
        'onSelectOnce': function (event, data) { noFilesToUpload = false; }, 
        'fileDesc': 'Media Files', 
        'fileExt': '*.jpg;*.jpeg;', 
        'sizeLimit': 27000000, 
        'multi': false, 
        'auto': false 
    }); 

</script>