![](/img/trans.png)
[英]When a user clicks the fineuploader button, how can I redirect them instead of showing the file selection dialog?
[英]How I can send the user to upload page instead showing the response
我發現此代碼可將進度條添加到上傳表單。 這段代碼在表格下方顯示了來自上傳頁面的響應,我希望用戶被重定向到上傳頁面並在其中看到響應0%
<div id="status"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
(function() {
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
$('form').ajaxForm({
beforeSend: function() {
status.empty();
var percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal);
},
complete: function(xhr) {
bar.width("100%");
percent.html("100%");
status.html(xhr.responseText);
}
});
})();
</script>
提前致謝
完成進度后只需更改window.location
因此,您的完整活動將是這樣的。
complete: function(xhr) {
bar.width("100%");
percent.html("100%");
status.html(xhr.responseText);
window.location.replace("http://stackoverflow.com");// or url of your choice
}
為了更好地理解javascript重定向,請參考此SO線程。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.