Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Pass variable from Perl-AJAX-Perl Date: Thu, 22 May 2014 19:16:26 +0200 Organization: PointedEars Software (PES) Lines: 52 Message-ID: <280169017.qlGG4jz0K9@PointedEars.de> References: <7akfv.180209$6A3.141820@fx29.iad> <0.cb8ce465599fb6e5a937.20140522122015BST.87lhturrf4.fsf@bsb.me.uk> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1400778989 30723 eJwFwYEBwCAIA7CXVKAt54CT/09YEoaNS0fAY2Jke06yxCGOmtcglUsv13XVy1gGFPvz6vkBBvUQxQ== (22 May 2014 17:16:29 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Thu, 22 May 2014 17:16:29 +0000 (UTC) User-Agent: KNode/4.12.4 X-User-ID: eJwNycERACEIBLCWENhFy+EQ+i/hfGYC42KFE3QM5uKJAl+H3uNdkKXV1mofSzIkz83SoUdzv57R2JGEJ+YHSXAVaA== Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. In my HTML page I call the first perl script: No, you do not. > ajaxRequest.open("POST", "http://127.0.0.1/cgi-bin/ajax/kba-search.pl", > true); > > which populates my select lists. No, most certainly it does not. If you use the XMLHttpRequest API directly, this only *prepares* to make an HTTP request to your locally installed Web server – it is the send() call that makes it –, and the part of your code that processes the resulting response populates the “select” elements (likewise, in the function whose reference is assigned to the “onreadystatechange” or “onload” property). In a sufficiently modern runtime environment, it would go like this: var ajaxRequest = new XMLHttpRequest(); ajaxRequest.open("POST", "http://127.0.0.1/cgi-bin/ajax/kba-search.pl", true); ajaxRequest.onload = function () { /* populate the “select” elements */ }; ajaxRequest.send(null); (A retrieval operation should be a *GET* operation instead. See REST.) > Then I need to capture the user choice (say a book title) so I can pass it > to another Perl script to return the data about that choice. > > How do I capture that data? In Perl or JavaScript? Since Perl usally does not run in the Web browser, you would have to use an ECMAScript implementation like JavaScript to access the DOM implementation in order to determine the user selection. Have you read the FAQ yet? If no, why not? Obviously you also have not read the XHR tutorial I have referred you to. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not Cc: me. / Bitte keine Kopien per E-Mail.