title: How to pass the percentage of the progress in code behind to Jquery progress bar?
body: <p>I have a background worker in asp.net. I would like to pass the percentage counted in progress changed and display it in jquery progress bar. Unfortunately,i found out it only update the progress bar once and only the progress is completed. </p>
  
  <h2>Jquery</h2>
  
  <pre><code>    $(document).ready(function() {
          $("#progressbar").progressbar();
                setTimeout(updateProgress, 100);
      });
  
     function updateProgress() {
                $.ajax({
                    type: "POST",
                    url: "Downloader.aspx/GetData",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: true,
                    success: function(msg) {
                        // Replace the div's content with the page method's return.
  
                        $("#progressbar").progressbar("option", "value", msg.d);
                    }
                });
            }
  </code></pre>
  
  <h2>Downloader.aspx.cs</h2>
  
  <pre><code>static BackgroundWorker _bw;
  public static int Percent { get; set; }
  
      protected void Button1_Click(object sender, EventArgs e)
      {
          _bw = new BackgroundWorker
          {
              WorkerReportsProgress = true,
              WorkerSupportsCancellation = true
          };
          _bw.DoWork += bw_DoWork;
          _bw.ProgressChanged += bw_ProgressChanged;
          _bw.RunWorkerCompleted += bw_RunWorkerCompleted;
  
          _bw.RunWorkerAsync("Hello world");
      }
  
      void bw_DoWork(object sender, DoWorkEventArgs e)
      {
  
          for (int i = 0; i &lt;= 100; i += 20)
          {
              if (_bw.CancellationPending) { e.Cancel = true; return; }
              _bw.ReportProgress(i);
              Thread.Sleep(1000);
          }
          e.Result = 123;
      }
  
      void bw_RunWorkerCompleted(object sender,
                                         RunWorkerCompletedEventArgs e)
      {
              percentage.Text = "Complete: " + e.Result;      // from DoWork
      }
  
      void bw_ProgressChanged(object sender,
                                      ProgressChangedEventArgs e)
      {
          Percent = e.ProgressPercentage;
      }
  
      [WebMethod]
      public static int GetData()
      {
          return Percent;
      }
  </code></pre>
  
  <p><strong>How to update the jquery progress bar once the bw_ProgressChanged detect any changes?</strong></p>