SPUG: Ajax question - js args

Adrian Hands AEH at akc.org
Tue Jun 20 06:30:05 PDT 2006

Not exactly answering your question the way you want, but I think what you need to do is:

<script type="text/javascript" language="javascript" src="http://builder.akc.org/ghawk.js"></script>
<script type="text/javascript" language="javascript">lookup_sellers( 'B000ERVJKO' );</script>


function lookup_sellers( somearg ) {

  var http_request;

  if (window.XMLHttpRequest) {          http_request = new XMLHttpRequest(); }
  else if (window.ActiveXObject) {      http_request = new ActiveXObject("Microsoft.XMLHTTP"); }

  if (http_request) {
        var obj;
        obj = document.getElementById('display');
        http_request.onreadystatechange = function() {
                if (http_request.readyState == 1) {
                        document.getElementById('display').innerHTML = '<img src=http://www.eskimo.com/~ghawk/ajax/loading6.gif>';
                if (http_request.readyState == 4) {
                        document.getElementById('display').innerHTML = http_request.responseText + ' ( ' + somearg + ' )';
        http_request.open("GET", "http://builder.akc.org/cgi-bin/test/ghawk.cgi", true);


-----Original Message-----
From: spug-list-bounces+aeh=akc.org at pm.org on behalf of Gary Hawkins
Sent: Tue 6/20/2006 3:58 AM
To: spug-list at pm.org
Subject: SPUG: Ajax question - js args


I'm working with Ajax and have a real basic question.  Meanwhile I'm going to
show what I'm doing in this Ajax example, because surely there will be
/(people)+/ that will find it intriguing or useful.


My question is simply:  How do I assign input arguments that are passed to a
.js file to variables in the js code?  That's new to me, I think I've read ~ 42
million web pages looking for that simple building block, and no joy.


Here's the example:  http://www.eskimo.com/~ghawk/ajax/test.htm


Once on the page, you'll see a little "rotating" animated gif while the
external page/information is being read.  The Perl script triggered by the js
code is looking for the number of sellers on this page:
?s=dvd&v=glance&n=130>  .where it says something like
4922?%5Fencoding=UTF8> 56 used & new (the number changes of course).


Once Perl has retrieved that page and extracted the number, it is returned to
the javascript (the js file that was pulled in by the htm page), and Ajax sees
the package has arrived, updates the div (id is 'display') and places the
digits there, replacing the image.


So, you might notice that in the javascript, I am sending an arg:


<script language="javascript"


...and that ASIN (Amazon Standard Identification Number) is different than the
one hardcoded (or medium coded) into the .cgi file.  Now all I have to do is
persuade js to take in that arg so it can be handed over to the Perl script.


In short, I need the js
equivalent+of+ at ARGV>  equivalent of @ARGV.




















-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/spug-list/attachments/20060620/93f854ec/attachment.html 

More information about the spug-list mailing list