[英]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.