简体   繁体   中英

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%

<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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM