views:

52

answers:

2

  I am developing a project which is built in CakePHP and using jQuery in it. I have a script which need to be called by an ajax request. This request do many manipulation in database and takes too much time. Between the execution it is writing its status in a seperate file so i can see the status of script execution. Every time it open the file write in it the status of execution and then close the file, to remove the problem of file lock.
    Now When this script is in progress I am sending another ajax request which just read that file and get the content back periodically after every 20 seconds. Now the problem is when first ajax request is busy with mysql, any other request to server will be on halt. Mysql creating processes of all these requests and put this request in sleep mode. I think its due to framework, cause on every request framework need to check the database. When the first main script completed all other request are also get completed.
   Is there any way that i can get the ajax progress ?? Correct me if I am wrong somewhere...!!! Thanks in advance.

A: 

If you are using jQuery for your Ajax needs you might want to look at the "async" option of the $.ajax method. The way i see it you want to show progress per the request currently being worked on. Now , this has a downside, it will lock whatever else you are doing but it will be showing correctly the progress of each "thread". I am not familiar with Cake, since i use Kohana. Now, mysql putting something to "sleep" is quite unlikely, it rather queues them. There is no real "progress" here, I would suggest to use something like $.ajaxStart or $.ajaxStop ( whatever that was called in jquery ) , as soon as you get a response back from the server you can hide the progress element.

gentec
Yes you are right I just want to show the progress of my first ajax request. This script iterate on more then 10 thousand records and i just want to show user that currently on which record the script is executing. After first request any other request create a process in mysql. I check by "show processlist;" command in mysql it create a process and put sleep status in Command column. I had already show the "Please wait script in progress..." message but i just want to show the actual process state to user.
Nehal
A: 

I did it. I just need to call the script which read the file and send back the data from a seperate php file. No need to call the framework...!!!

Nehal