ファイルをアップロードした後に関数を実行するアップロードスクリプトを使用しています。私はこの関数をjavascript変数の値を再割り当てする必要があります。私は私のonComplete関数の中にある値に "trackid"を再割り当てする必要があります。誰か助けてくれますか?jquery関数 - グローバルjavascript変数を再割り当て
編集:もう少し説明が...私は自分のページにこのアップロードスクリプトの2つのインスタンスを持っています。私は最初のアップローダからの応答を受け取り、それをURLパラメータとして2番目のアップローダに割り当てる必要があります。それはdocument.readyと関係がありますか?コードを更新します。
第一スクリプト:
<script type="text/javascript">
trackid = 9999999;
</script>
<script type="text/javascript">
jQuery(document).ready(function() {
$('#mainftp').uploadify({
'uploader' : 'js/uploadifyposted/uploadify.swf',
'script' : 'js/uploadifyposted/uploadify.php?<?php echo urlencode("privateFolderWav=" . $privateFolderWav . "&userid=" . $userid. "&songid=" . $songid);?>',
'multi' : true,
'auto' : true,
'height' : '32', //height of your browse button file
'width' : '250', //width of your browse button file
'sizeLimit' : '51200000', //remove this to set no limit on upload size
'simUploadLimit' : '3', //remove this to set no limit on simultaneous uploads
'buttonImg' : 'img/browse.png',
'cancelImg' : 'img/cancel.png',
'folder' : '<?php echo $privateFolderWav;?>', //folder to save uploads to
onProgress: function() {
$('#loader').show();
},
onComplete: function(event, queueID, fileObj, response, data, trackid) {
$('#loader').hide();
$('#allfiles').load(location.href+" #allfiles>*","");
$('#filesUploaded').attr('value', ''+response+'');
trackid = response;
alert(trackid);
//location.reload(); //uncomment this line if youw ant to refresh the whole page instead of just the #allfiles div
}
});
$('ul li:odd').addClass('odd');
});
</script>
第二スクリプト:
<script type="text/javascript">
jQuery(document).ready(function() {
$('#mainftp2').uploadify({
'uploader' : 'js/uploadifymultiple/uploadify.swf',
'script' : 'js/uploadifymultiple/uploadify.php?<?php echo urlencode("songid=" . $songid . "&userid=" . $userid . "&trackid=");?>'+trackid,
'multi' : true,
'auto' : true,
'height' : '32', //height of your browse button file
'width' : '250', //width of your browse button file
'sizeLimit' : '51200000', //remove this to set no limit on upload size
'simUploadLimit' : '3', //remove this to set no limit on simultaneous uploads
'buttonImg' : 'img/browse.png',
'cancelImg' : 'img/cancel.png',
'folder' : '<?php echo $multiFolder?>', //folder to save uploads to
onProgress: function() {
$('#loader2').show();
},
onComplete: function(event, queueID, fileObj, response, data) {
$('#loader2').hide();
$('#allfiles2').load(location.href+" #allfiles2>*","");
$('#filesUploaded2').attr('value', ''+response+'');
//location.reload(); //uncomment this line if youw ant to refresh the whole page instead of just the #allfiles div
}
});
$('ul li:odd').addClass('odd');
});
</script>
のonCompleteの中で呼び出されている第2の機能を持っている必要があり、どのような変数は 'trackid'は' onComplete'以内に含むようにしたいですか? – Bartek
あなたは何を持っているのですか? –
あなたが持っているものはうまく動作するはずです。その適切に書かれた。この変更されたグローバル変数は、一度変更されるとどうなりますか? – Marlin