Display percentage value of progress bar during AJAX upload
<p>I can't seem to display my current upload value on my progress bar. I know how to do it, if the progress bar has stopped, but it won't work if I want it to update all the time.</p>

<pre><code>xhr.upload.onprogress = function(e) {
    if (e.lengthComputable) {
        var percentage = (e.loaded / e.total) * 100;
        $('div.progress-bar').css('width', percentage + '%');
    }
};
</code></pre>

<pre class="lang-html prettyprint-override"><code>&lt;div class="progress progress-striped active hide"&gt;
    &lt;div style="width: 0%" class="progress-bar progress-bar-striped active"&gt;
        &lt;script&gt;
            $("div.progress-bar").text($("div.progress-bar").width() + "%" );
        &lt;/script&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>The progress bar itself runs fine. This code just outputs "0%" all the time, as the initial width()-value is 0. I want it to increase along with the progress bar dynamically.</p>

<p>Thanks in advance!</p>