简体   繁体   English

如何发送用户上传页面,而不显示响应

[英]How I can send the user to upload page instead showing the response

I have found this code to add progress bar to the upload form. 我发现此代码可将进度条添加到上传表单。 This code is showing the response from upload page under the form, I want the user to be redirected to the upload page and see the response there 0% 这段代码在表格下方显示了来自上传页面的响应,我希望用户被重定向到上传页面并在其中看到响应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>

Thanks in advance 提前致谢

Just change the window.location after the progress is completed 完成进度后只需更改window.location

So your complete event will be something like this. 因此,您的完整活动将是这样的。

 complete: function(xhr) {
               bar.width("100%");
               percent.html("100%");
               status.html(xhr.responseText);
               window.location.replace("http://stackoverflow.com");// or url of your choice
            }

To better understand javascript redirects refer to this SO thread. 为了更好地理解javascript重定向,请参考此SO线程。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当用户单击fineuploader按钮时,如何重定向他们而不显示文件选择对话框? - When a user clicks the fineuploader button, how can I redirect them instead of showing the file selection dialog? 如何使用json而不是jade发送响应? - How could I send response using json instead of jade? 如果用户说了些什么,我如何发送系统响应? NodeJS/socketio - How can I send a system response if a user says something? NodeJS/socketio 如何在不显示地址栏中的值的情况下将值发送到下一页 - How can i send the values to the next page without the showing the values in the address bar 我不知道为什么JSON响应无法预言ajax的回叫,而是由浏览器显示并停留在我发送请求的页面上 - I don't know why JSON response can't forword ajax's call back but showing by browser and stay on the page where I send request 如何通过打开新窗口执行OAuth请求,而不是从当前页面重定向用户? - How can I do OAuth request by open new window, instead of redirect user from current page? Ajax请求将整个页面发回,而不是我在Response.Write中发送的文本 - Ajax requests sends the whole page back instead of text i send in Response.Write 如何将数据发送给将在网页浏览之间保留但不会重新发送到服务器的用户? - How can I send data to a user that will persist between web page views, but which won't be resent to the server? 如何将二进制数据作为文件上传发送到服务器? - How can I send binary data to server as a file upload? 节点,如何在节点/快速应用上发送响应头? - Node, how can I send response headers on a node/express app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM