Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24350
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Pass variable from Perl-AJAX-Perl |
| Date | 2014-05-22 17:30 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <lllc6u$nch$2@dont-email.me> (permalink) |
| References | <7akfv.180209$6A3.141820@fx29.iad> <0.cb8ce465599fb6e5a937.20140522122015BST.87lhturrf4.fsf@bsb.me.uk> <Xxpfv.2613762$g45.648553@fx10.iad> |
On Thu, 22 May 2014 12:25:27 -0400, trudge wrote:
> On 14-05-22 7:20 AM, Ben Bacarisse wrote:
>> trudge <nospam@softouch.on.ca> writes:
>>
>>> I'm stuck on a problem I'm having with a project. I have a library
>>> built on a MySQL db and am trying to access it via AJAX & Perl.
>>>
>>> I start with an HTML page calling a Perl script to populate several
>>> select lists (title, author, subject). User then picks an option (say
>>> book title) which then needs to call another Perl script to provide
>>> details of that choice.
>>>
>>> I am stuck trying to pass a variable (say the option choice) back to
>>> AJAX so that I can use it to call the next Perl script.
>>>
>>> Is this something that is even possible with AJAX?
>>
>> Yes. You have a client-side script making an HTTP request. That
>> script has access to the DOM (the internal representation of the
>> document your user is looking at) which includes selection options,
>> checkbox states and so on.
>>
>> The problem I have is understanding where the problem is. What have
>> you got? What have you tried?
>>
>> Maybe the problem is the form that the request will take? The simplest
>> option is to pass the data to the server in the query string of the
>> requested URL. E.g. your script might request
>> "http://myserver/info?isbn=42".
>>
>>
> Hi Ben and thank you for the advice and apologies for the lack of
> details. In my HTML page I call the first perl script:
>
> ajaxRequest.open("POST", "http://127.0.0.1/cgi-bin/ajax/kba-search.pl",
> true);
>
> which populates my select lists. 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? Once I have that then
> I can take your suggestion and use it in a GET or POST.
You capture anything that happens in the form in javascript. You then
have to encode it into an ajax request, either using the get or post
methods, which you then send to your perl script.
Your perl script will probably either use a library to extract the
request variables from the http request, or will need to parse the input
it receives from the web server. In either case, my knowledge of such
things is limited, and as (a) it's very easy to introduce security
vulnerabilities by parsing such input in an unsafe manner, (b) perl isn't
really on topic here, and (c) I haven't user perl for years; I'm not
going to suggest any solutions to you - I suggest you find a perl
newsgroup where they know about such things.
--
Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Pass variable from Perl-AJAX-Perl trudge <nospam@softouch.on.ca> - 2014-05-22 06:18 -0400
Re: Pass variable from Perl-AJAX-Perl Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-05-22 12:20 +0100
Re: Pass variable from Perl-AJAX-Perl trudge <nospam@softouch.on.ca> - 2014-05-22 12:25 -0400
Re: Pass variable from Perl-AJAX-Perl Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-22 19:16 +0200
Re: Pass variable from Perl-AJAX-Perl John Harris <niam@jghnorth.org.uk.invalid> - 2014-05-23 10:13 +0100
Re: Pass variable from Perl-AJAX-Perl Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-22 17:30 +0000
Re: Pass variable from Perl-AJAX-Perl Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-22 13:27 +0200
Re: Pass variable from Perl-AJAX-Perl Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-22 17:04 +0000
Re: Pass variable from Perl-AJAX-Perl trudge <nospam@softouch.on.ca> - 2014-05-22 13:41 -0400
csiph-web