2

I have created a dashboard for my application with multiple widgets. Each widget having its own corresponding functions. During the initial load of the dashboard all widgets are calling their own functions through $(document).ready() with ajax. The problem with this scenario is at a time only one function is executed and only after successful execution of first function second one executed, like wise all remaining functions are executed. If am having 10 widgets then all are displayed one after another.

I need to execute all functions simultaneously based on their execution time. What i mean is one widget should not wait for the completion of other widget to finish but has to process and display the results simultaneously as and when its function completes its process.

4
  • 2
    Can you post your sample code? Because things are not getting clear form this. Commented Oct 25, 2012 at 4:20
  • if the $.ajax is cross domain (jsonp) the wait is necessary, else the option async: true is default. can you post your code for more explain Commented Oct 25, 2012 at 4:41
  • I think there is no problem in ajax call. The problem is, same browser sending multiple request to the server simultaneously, but server serves browser requests one by one. But i need to change server behavior to process multiple requests simultaneously. And the functions are also available in same domain, not a cross-domain request. Commented Oct 25, 2012 at 6:47
  • To understand the problem clearly, If am opening one php page in browser which consumes 30 sec to execute fully, in between if am opening another page from same domain, the new page is starting only after the completion of the previous request i.e after 30 sec. I hope i have clearly explained the problem now. Help me to resolve the same. Commented Oct 25, 2012 at 7:54

1 Answer 1

3

Finally i got the answer for above problem,

Am using file based session, So PHP will lock session files for each request and maintain that lock until the script terminates/exits.

If we need to unlock the PHP Session file in our script, we can use session_write_close() in our script. That will unlock the session file and will utilize the same for that instance.

In the same time the session_write_close() function will make all requests as serial, because all requests struggling for the same single session file.

So from session_write_close(), i have rectified my problem.

Thank you @kalpeshpatel and @iJD for your response.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.