Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Gene Wirchenko Newsgroups: comp.lang.javascript Subject: Re: XHR: Passing Parameters to a ready-state-change Function Date: Wed, 05 Sep 2012 17:30:39 -0700 Organization: A noiseless patient Spider Lines: 46 Message-ID: References: <09ef48tfsgucbl7m49ggao3be5r0kb7v13@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="c0a6a1dc41fc92eb7000e57afbd16211"; logging-data="26997"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+674994Ht2pjTBcqL8oS3YQfJBf4huV6Q=" X-Newsreader: Forte Agent 4.2/32.1118 Cancel-Lock: sha1:otokVlvALgRapO3tZ0Nw5DHZghA= Xref: csiph.com comp.lang.javascript:15728 On Wed, 05 Sep 2012 17:46:49 -0400, Jim T. wrote: >On Wed, 05 Sep 2012 13:53:26 -0700, Gene Wirchenko >wrote: > >>Dear JavaScripters: >> >> Is there any way to pass parameters to the ready-state-change >>function that checks the progress of a request? I am currently using >>a global. I would prefer not to. [snip] >Something like this maybe? > >oRequest.onreadystatechange= > function() > { > var state = 0; > > return function() > { > state++; > > if ( state == 1) > > else > > }; > } (); Uh, no. The "1" and "2" in the names were not meant to imply any order. I am working on the general design for Web pages which would allow CRUD. Depending on the request to be performed, the result back from the server will be handled differently. Request types could be in any order. I also prefer to have each scenario broken out into its own function. IMHO, debugging Web code is mucky enough without having longer-than-necessary functions. Sincerely, Gene Wirchenko