파일을 업로드 한 후에 함수를 실행하는 업로드 스크립트를 사용하고 있습니다. javascript 변수의 값을 다시 할당하려면이 함수가 필요합니다. 내 onComplete 함수 안에있는 값에 "trackid"를 다시 할당해야합니다. 누구든지 나를 도울 수 있습니까?jquery 함수 - 전역 자바 스크립트 변수를 다시 할당
편집 : 조금 더 설명 ... 내 페이지에이 업로드 스크립트의 인스턴스가 2 개 있습니다. 첫 번째 업 로더의 응답을 URL 매개 변수로 두 번째 업 로더에 할당해야합니다. 그게 그 document.ready와 관련이 있습니까? 내 코드를 업데이트 할 것입니다.
1 스크립트
<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>
2 스크립트
<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>
''trackid'가'onComplete' 내에 포함되기를 원하는 변수는 무엇입니까? – Bartek
그래서 문제는 무엇입니까? –
당신이 가지고있는 것이 잘 작동해야합니다. 그것의 제대로 써진. 이 수정 된 전역 변수는 일단 변경되면 어떻게해야합니까? – Marlin