SPUG: Ajax question - js args

Gary Hawkins ghawk at eskimo.com
Tue Jun 20 00:58:06 PDT 2006


Hiya,

 

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:
http://www.amazon.com/exec/obidos/ASIN/B000ERVJM2/
<http://www.amazon.com/gp/product/B000ERVJM2/ref=pd_ts_d_31/102-0990943-3824922
?s=dvd&v=glance&n=130>  .where it says something like
<http://www.amazon.com/gp/offer-listing/B000ERVJM2/ref=dp_olp_2/102-0990943-382
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"
src="http://www.eskimo.com/~ghawk/ajax/test.js?a=B000ERVJKO"></script>

 

...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
<http://www.google.com/search?as_q=&num=100&hl=en&btnG=Google+Search&as_epq=js+
equivalent+of+ at ARGV>  equivalent of @ARGV.

 

Thanks,

 

Gary

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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


More information about the spug-list mailing list