2012-04-14 5 views
0

Ich habe das Problem jetzt selbst gelöst, unten ist die Lösung: Kein Problem mehr. Ich schreibe dies nur, um meinen Text zu validieren.Uploadify - Wie erfasse ich die neu erstellte ID für Skriptdaten?

<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> 

Vielen Dank! Ich habe das Problem jetzt selbst gelöst, unten ist die Lösung: Kein Problem mehr. Ich schreibe dies nur, um meinen Text zu validieren.

+0

Wenn Sie das Problem selbst gelöst haben, bitte ** beantworten Sie Ihre eigene Frage **. Und löschen Sie nicht die ursprüngliche Frage, da Antworten außerhalb des Kontextes der ursprünglichen Frage für jeden, der in Zukunft auf diese Seite stoßen könnte, nutzlos sind. –

+0

@Yi Jiang, nun, ich wollte nur sagen, dass ich kein Problem mehr hatte, aber die stackoverflow-Validierung erlaubte mir nicht, meine eigene Frage vorher in 6 Stunden zu beantworten (wegen meines schlechten Rufs), ich dachte es wäre dumm wegzugehen Die Antwort ist offen, wenn ich kein Problem mehr hatte. So versuchte ich es zu sagen. Vielleicht hätte ich stattdessen einen Kommentar verwenden sollen. – rune007

Antwort

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> 
Verwandte Themen