PDA

View Full Version : Synchronous Ajax Calls



Nagadev
23 Sep 2009, 10:05 AM
From other posts I understand that Ext doesnt support Synchronous Ajax Calls. But my requirement is , I will be processing or calling webservice call which may take few minutes at server side. So if I use asynchronous call it will get timedout for 50000 milliseconds which results in failure of the ajax call.

Can anyone suggest me a way that my screen should wait till the server completes its process. Increasing timeout will not solve my problem because server may process records for more time next time.

zhegwood
23 Sep 2009, 10:20 AM
The only thing I can think of is to chunk the data-getting into smaller batches. Send a start value in the params for the ajax call & on the server-side start at that value and return, say, 1000 records at a time. Then in the response send a completed flag. Wrap that in a while loop and you should be good.

On a side note, you might run into problems on the js side actually doing anything with that amount of data once you get it... Unresponsive script messages could happen if you do any looping.

Mike Robinson
23 Sep 2009, 10:30 AM
I do not know what web-service you are talking to, or if you have any control over it. But, if you do...

If the task being performed takes a long time to complete, then in effect it is what we old-timers :s would call "a batch job."

//JSTASK JOB (123,456),'BLAST FROM THE PAST'
//STEP1 EXEC DSN=...

(whups! wrong decade!)

Seriously... you ought to define one web-service request that starts the background activity and gives you some handle that you can then use to check on it. Other web service requests let you poll the status of the activity, and maybe to define some kind of pro-active notification. Finally, other requests would let you determine how many results there are, and to obtain slices of the information. Finally, a request would allow you to indicate to the mainfram... I mean, to the host... that the output can now be discarded.