josedasilva @ 16:51

Qua, 20/09/06

Pois é, o uso detse tipo de técnicas, onde não temos o total controlo sobre a velocidade e ordem de recepção de pedidos leva por vezes a histórias destas, aliás é por isso mesmo se chama assíncrono.

Num dos testes de laboratório que tanto gosto de efectuar, estive a testar multiplos pedidos simulâneos assincronos, o que me levou à descoberta de um possível problema, quando não temos em mente que dois pedidos assíncronos, efectuados no mesmo momento, podem ter tempos de resposta variáveis.

Imaginemos a seguinte iteracção:

1. Click num qualquer botão leva ás seguintes acções:

1. Envio de pedido para alterar o estado de um registo na base de dados e actualização da "div" actual
2. Envio de pedido de actualização de uma segunda "div" com o registo editado anteriomente já actualizado

A ideia é simples, imaginem-se duas listas, onde numa se listam registos activos e na outra se listam registos inactivos. Imagine-se que se deseja inactivar um registo, a estratégia passa por actualizar o registo na base de dados como inactivo e actualizar ambas as listas de modo a que o registo passe a constar imediatamente da lista certa.



  1. function deleteRecord() {

  2. doAjaxTODeleteRecordAndUpdateDeletedRecordList() ;

  3. doAjaxTOUpdateActiveRecordsList();

  4. }



O problema ocorre quando o pedido assíncrono de edição do registo para estado inactivo é executado após o pedido de actualização das listas. No meu caso o registo de edição era efectuado antes da actualização das listas, umas vezes e noutras nem por isso.

A solução poderia passar por:



  1. function deleteRecord() {

  2. doAjaxTODeleteRecordAndUpdateDeletedRecordList();

  3. setTimeout(doAjaxTOUpdateActiveRecordsList(),1000);

  4. }



A solução pode passar por obrigar o segundo pedido a ter um delay de alguns micro segundos, não garante que é tratado antes, mas garante que existem infimas probabilidades de não o ser. Ou então executar apenas o segundo pedido quando recebermos a resposta do primeiro.
UPDATE [21 Set 2006]
O Marco, do Webaserio, apresentou uma outra solução para o problema, basicamente a alternativa dele seria actualizar as duas listas na mesma chamada assíncrona, eliminando assim uma das chamadas e conseguindo garantir a ordem das respostas. Outra das soluções falada, em conversa com ele, era a da possibilidade de efectuar a actualização das listas apenas com javascript, e esta seria a solução mais eficaz, que sonsistia em mudar os elementos de lista usando javascript, directamente no DOM.Existem diversas formas de efectuar o mesmo procedimento, vamos ter de optar pela mais correcta dado o problema.

Tags:

Re viagra cello. @ 17:27

Seg, 30/07/07

 

Re viagra cello....

Re viagra cello....

Prozac use in dogs. @ 10:58

Sex, 03/08/07

 

Prozac use in dogs....

Prozac use in dogs....

EcRXNeMHSWNMvlaRqS @ 18:06

Seg, 22/09/14

 

XkTAnd jlfilwktmcmn (http://jlfilwktmcmn.com/), [url=http://thfzowwmgaix.com/]thfzowwmgaix[/url], [link=http://qvrzjbpvylca.com/]qvrzjbpvylca[/link], http://rrjneiiwqxxk.com/

sUGopFpTsD @ 09:51

Sab, 15/11/14

 

shoprite pharmacy rockaway nj, nolvadex cutting steroid (http://support.roomprotech.com/entries/41705979-With-Discount-Generic-Tamoxifen-in-Walsall-clomid-tamoxifen-nolvadex-side-effects), [url="http://support.roomprotech.com/entries/41705979-With-Discount-Generic-Tamoxifen-in-Walsall-clomid-tamoxifen-nolvadex-side-effects"]nolvadex cutting steroid[/url], http://support.roomprotech.com/entries/41705979-With-Discount-Generic-Tamoxifen-in-Walsall-clomid-tamoxifen-nolvadex-side-effects nolvadex cutting steroid, ynn,

BwbSnuwOULNQidw @ 22:49

Sab, 15/11/14

 

student heal pharmacy chico ca, salbutamol ventolin expectorant (http://support.savincom.co.uk/entries/89872693-Free-Airmail-Shipping-Generic-Albuterol-2mg-in-Little-Rock-overdose-ventolin-children), [url="http://support.savincom.co.uk/entries/89872693-Free-Airmail-Shipping-Generic-Albuterol-2mg-in-Little-Rock-overdose-ventolin-children"]salbutamol ventolin expectorant[/url], http://support.savincom.co.uk/entries/89872693-Free-Airmail-Shipping-Generic-Albuterol-2mg-in-Little-Rock-overdose-ventolin-children salbutamol ventolin expectorant, 31177, ventolin online kaufen (http://toleleamon.nation2.com/index.php?page=1309618608), [url="http://toleleamon.nation2.com/index.php?page=1309618608"]ventolin online kaufen[/url], http://toleleamon.nation2.com/index.php?page=1309618608 ventolin online kaufen, 443,

oEUnOYmAh @ 05:00

Dom, 16/11/14

 

wellers hill pharmacy, generic of ventolin (http://jogisipo.soup.io/post/446763248/Buy-Cheap-Ventolin-With-Free-Bonus-Pills), [url="http://jogisipo.soup.io/post/446763248/Buy-Cheap-Ventolin-With-Free-Bonus-Pills"]generic of ventolin[/url], http://jogisipo.soup.io/post/446763248/Buy-Cheap-Ventolin-With-Free-Bonus-Pills generic of ventolin, orwur, can pregnant women have ventolin (http://support.gobalto.com/entries/39477419-Purchase-Generic-Albuterol-With-10-Discount-dose-of-ventolin-for-nebulizer), [url="http://support.gobalto.com/entries/39477419-Purchase-Generic-Albuterol-With-10-Discount-dose-of-ventolin-for-nebulizer"]can pregnant women have ventolin[/url], http://support.gobalto.com/entries/39477419-Purchase-Generic-Albuterol-With-10-Discount-dose-of-ventolin-for-nebulizer can pregnant women have ventolin, =DDD, often do you use your ventolin (http://tinnewsdownham.jottit.com/generic_albuterol_2mg_without_prescription), [url="http://tinnewsdownham.jottit.com/generic_albuterol_2mg_without_prescription"]often do you use your ventolin[/url], http://tinnewsdownham.jottit.com/generic_albuterol_2mg_without_prescription often do you use your ventolin, 6284, ventolin hfa expired (http://holisticresults.com.au/ForumRetrieve.aspx?ForumID=2252&TopicID=783889&NoTemplate=False), [url="http://holisticresults.com.au/ForumRetrieve.aspx?ForumID=2252&TopicID=783889&NoTemplate=False"]ventolin hfa expired[/url], http://holisticresults.com.au/ForumRetrieve.aspx?ForumID=2252&TopicID=783889&NoTemplate=False ventolin hfa expired, yzg,

GPDItFeDqTVYqcsP @ 15:57

Dom, 16/11/14

 

pharmakokinetic, can you take prednisone for sinus infection (http://snk.to/D8yF), [url="http://snk.to/D8yF"]can you take prednisone for sinus infection[/url], http://snk.to/D8yF can you take prednisone for sinus infection, cwd, cost of cymbalta in australia (http://support.cycla.com/entries/92605776-Order-Cheap-Generic-Duzela-20mg-With-Visa-Online-No-Membership-zoloft-now-cymbalta), [url="http://support.cycla.com/entries/92605776-Order-Cheap-Generic-Duzela-20mg-With-Visa-Online-No-Membership-zoloft-now-cymbalta"]cost of cymbalta in australia[/url], http://support.cycla.com/entries/92605776-Order-Cheap-Generic-Duzela-20mg-With-Visa-Online-No-Membership-zoloft-now-cymbalta cost of cymbalta in australia, 8-PP,

qTEBVFYGvjahfPXoiHF @ 04:31

Seg, 17/11/14

 

testing for impurities in pharmaceutical analysis, suprax patient info (http://help.socialchorus.com/entries/38027895-With-Visa-Online-No-Prescription-No-Membership-Generic-Suprax-in-Kansas-City-cefixime-in-acute-sinus), [url="http://help.socialchorus.com/entries/38027895-With-Visa-Online-No-Prescription-No-Membership-Generic-Suprax-in-Kansas-City-cefixime-in-acute-sinus"]suprax patient info[/url], http://help.socialchorus.com/entries/38027895-With-Visa-Online-No-Prescription-No-Membership-Generic-Suprax-in-Kansas-City-cefixime-in-acute-sinus suprax patient info, 647, penicillin tetracycline antagonism (http://support.sepionet.com/entries/93889776-FDA-Approved-Tetracycline-Capsules-Without-Prescription-in-Jersey-City-tetracycline-to-cats), [url="http://support.sepionet.com/entries/93889776-FDA-Approved-Tetracycline-Capsules-Without-Prescription-in-Jersey-City-tetracycline-to-cats"]penicillin tetracycline antagonism[/url], http://support.sepionet.com/entries/93889776-FDA-Approved-Tetracycline-Capsules-Without-Prescription-in-Jersey-City-tetracycline-to-cats penicillin tetracycline antagonism, feca,

MBRAOhOYgwfWzOk @ 10:13

Seg, 17/11/14

 

ashland pharmacy nebraska, tetracycline and fetus (http://www.business-money.com/ForumRetrieve.aspx?ForumID=729&TopicID=371142&NoTemplate=False), [url="http://www.business-money.com/ForumRetrieve.aspx?ForumID=729&TopicID=371142&NoTemplate=False"]tetracycline and fetus[/url], http://www.business-money.com/ForumRetrieve.aspx?ForumID=729&TopicID=371142&NoTemplate=False tetracycline and fetus, fik, using tetracycline to treat acne (http://rutsnandersre.webpin.com/blog_426517_Online-Without-A-Rx-FDA-Approved-Terarid-500mg-in-Pueblo-tetracycline-and-derivatives.html), [url="http://rutsnandersre.webpin.com/blog_426517_Online-Without-A-Rx-FDA-Approved-Terarid-500mg-in-Pueblo-tetracycline-and-derivatives.html"]using tetracycline to treat acne[/url], http://rutsnandersre.webpin.com/blog_426517_Online-Without-A-Rx-FDA-Approved-Terarid-500mg-in-Pueblo-tetracycline-and-derivatives.html using tetracycline to treat acne, 11933,

BlUBpAmG @ 16:19

Seg, 17/11/14

 

sauflon pharmaceutical, grapefruit grapefruit juice may interact levitra (http://helpdesk.onsitetechnicalsupport.com/entries/90583106-Where-To-Purchase-Cheapest-Super-Zhewitra-Vardenafil-20mg-Dapoxetine-60mg-With-Visa-No-Prescription-), [url="http://helpdesk.onsitetechnicalsupport.com/entries/90583106-Where-To-Purchase-Cheapest-Super-Zhewitra-Vardenafil-20mg-Dapoxetine-60mg-With-Visa-No-Prescription-"]grapefruit grapefruit juice may interact levitra[/url], http://helpdesk.onsitetechnicalsupport.com/entries/90583106-Where-To-Purchase-Cheapest-Super-Zhewitra-Vardenafil-20mg-Dapoxetine-60mg-With-Visa-No-Prescription- grapefruit grapefruit juice may interact levitra, :[[, intrathecal baclofen pumps (http://moi.zendesk.com/entries/39269539-Where-To-Buy-Lioresal-10mg-in-Seville-baclofen-startle-reflex), [url="http://moi.zendesk.com/entries/39269539-Where-To-Buy-Lioresal-10mg-in-Seville-baclofen-startle-reflex"]intrathecal baclofen pumps[/url], http://moi.zendesk.com/entries/39269539-Where-To-Buy-Lioresal-10mg-in-Seville-baclofen-startle-reflex intrathecal baclofen pumps, msvhsc,

Blog pessoal de José Silva. Sou programador informático, nos últimos anos dedicado quase exclusivamente ao PHP.
Setembro 2006
Dom
Seg
Ter
Qua
Qui
Sex
Sab

1
2

3
4
5
6
7
8
9

10
12
13
14
16

17
18
19
21
23

24
25
26
27
28
29
30


Pesquisar
 
blogs SAPO