After a lot of digging i came up with using $.get() method and implemented it as follow -
var id = setInterval(frame, 1000);
function frame()
{
if (progressBar.dataset.size == 100)
{
clearInterval(id);
}
else {
$.get('Progress1.txt', function (data1) {
progressBar.dataset.size = data1;
foreground.style.width = data1 + '%';
foreground.className += ' ' + newClass;
progressPercent.innerHTML = data1 + '%';
});
}
}
e.g if the text file content is 40 then i have to set the width of my progress bar as 40%. The value of text file keeps changing dynamically in my backend(C#). so i have to keep checking it until the content of text file reaches 100 in frontend(jQuery/JavaScript). Now, the page runs fine for the first time. But when i try to change the content of text file manually it is not reflected in my progress bar. Moreover after running it again for second time i get the same content that i used first time in my text file.