PDA

View Full Version : wait or sleep?



Capi666
9 Jun 2008, 12:42 AM
Hi experts,

can i do a wait or sleep with javascript?

Thanks in advance,

Animal
9 Jun 2008, 1:08 AM
No. What are you wanting to do?

Capi666
9 Jun 2008, 1:20 AM
I

Animal
9 Jun 2008, 1:45 AM
You have to postprocess all Ajax requests in the callback.

fangzhouxing
9 Jun 2008, 3:04 AM
hi, Capi666,if you use Doug Hendricks‘s ext-basex.js, you can add 'async' config item to make Ajax request in synchronized mode.

devnull
9 Jun 2008, 7:41 AM
that goes against conventional event based programming practices though, and should only be used when there is no other possible way to do things. i have yet to see a situation where this is required...

hendricd
9 Jun 2008, 7:54 AM
Here (http://extjs.com/forum/showthread.php?p=120278#post120278)is an asynch pattern that you could look at. I use it frequently.

Capi666
17 Jun 2008, 7:30 AM
I don

devnull
17 Jun 2008, 8:19 AM
Using recursion should work (though I am curious why you use 'i' as the loop var and then reference a 'j' value in the url...):


var i = 0;
var fetchUrl = function(options,success,response){
//test for valid 'response' and do something with it here
if (response) {
//...
}
//send a request
if (i < 5) {
Ext.Ajax.request({
url: "http://localhost:4444/FV/jsp/aplicacion/pedido_camp/posicion.jsp",
method: "GET",
params: {
po: Ext.getCmp('prod').getValue()+";"+matriz+";"+mes+";"+semana+";"+eval('value'+j)
},
callback: fetchUrl
});
}
i++;
}
fetchUrl();

Note that I have never used recursion in javascript, but in theory this should make 5 requests one after the other. You may also want to use the success event rather than callback, or look at the success value passed in if you want to abort subsequent calls if one fails.
I also took the liberty of showing you the value of using the params config :)

Capi666
18 Jun 2008, 7:25 AM
I copy a part of my problem... My code is bigger, i can

hardeep.kwatra
21 Mar 2011, 3:27 AM
Hi,

I am facing a different kind of problem. i have a grid which contains a country combo and the city combo.

the city store gets loaded as soon as the user selects the country from the drop down (passing the country code as parameter).

the issue comed when we show the grid to the user with the saved values in the DB. i've used the renderer for grid coumns to show the country name instead of country code and the same is for city. this is where the problem arises.

as my city store is not already loaded i am loading it in the renderer of the country coumn but the rendere of the city column does not wait for the store to be loaded and returns the city code itself so, the city code is shown in the city combo.

is there any way to make city column renderer to wait till the store gets loaded?

any help is appreciated in advance