tags:

views:

54

answers:

1

I am developing a progress bar using Ajax. My client side code is working fine, but I have issue at server side. I am using C based CGI.

if(i == inc && pb_inc<=100)
{
fptr = fopen("progress_bar.txt", "w");
fprintf(fptr,"%d", j);
fclose(fptr);
pb_inc++;
}

basically I am increasing progress bar after certain number of bytes. What I see here is that the CGI doesn't let display any data to text file until it has sent all the data to file one by one.

i have referred to http://www.redips.net/javascript/ajax-progress-bar/

Any idea whats happening here?

A: 

Does calling fflush(fptr) improve things? I'm assuming the client side is requesting progress_bar.txt, which may not be updating as you expect.

Tim Post
No, fflush(fptr) doesn't change anything. Yes, client is requesting for progress_bar.txt, although the text file gets updated but it doesn't get available for reading at the time of update, only after its DONE updating, it is available.
Punit