Google Answers Logo
View Question
 
Q: Is it possible to get Data into a JavaScript Code by calling a CGI? ( No Answer,   6 Comments )
Question  
Subject: Is it possible to get Data into a JavaScript Code by calling a CGI?
Category: Computers > Programming
Asked by: springshopping-ga
List Price: $20.00
Posted: 31 Dec 2002 07:20 PST
Expires: 30 Jan 2003 07:20 PST
Question ID: 135474
My CGI is able to return data in every format you like. Here comes the question:


My CGI is at:

    www.server1.com/cgi.php

My external Pages are at:

    www.server2.com/form1.html
    
    ...links to...
    
    www.server2.com/page2.html
    
    ...links to...
    
    www.server2.com/page3.html


I would like to receive Data from my CGI on wwww.server1.com into a JavaScript
on page2.html without using any scripting tools on www.server2.com like perl,
php, etc. It is possible to embed javascript code on form1.html, too.

The data received is used to modify the design of page2.html .


Best regards,

springshopping-ga

Request for Question Clarification by mrbuzz-ga on 31 Dec 2002 10:25 PST
Hi springshopping-ga,

JavaScript can retrieve source files from any domain using the 'src='
parameter in the <script> tag.  However, you will have to layout your
HTML code wrapped in JavaScript.  Would it be acceptable to design the
page in JavaScript?  For example, instead of having standard HTML tags
such as:

<img src="blah.jpg" border=0>

with JavaScript, it'll be like:

document.write ('<img src="blah.jpg" border=0>');

This allows you to script anything you'd like using cgi or php or any
other server-side scripting language on server1.com and you will not
need any server-side scripting language on server2.com and still
accomplish server-side scripting capabilities.  If this is acceptable
to you, please let me know and I'll post a full answer.

Regards,
mrbuzz-ga

Request for Question Clarification by mathtalk-ga on 31 Dec 2002 13:52 PST
Hi, springshopping-ga:

I assume that by JavaScript you mean server-side scripting as opposed
to client-side.  Therefore the details of doing what you want will
depend mainly on the Web server used.  Which do you use?

A natural approach (at least to me) would be to pull an XML response
from server 1 (running CGI) and manipulate that result in the
server-side JavaScript in the pages on server 2 (to generate HTML
output).  Again, the details will depend on your Web server.  Once you
identify that, the appropriate experts here can point you to working
examples.

regards, mathtalk-ga

Request for Question Clarification by joseleon-ga on 01 Jan 2003 10:43 PST
Hello:
  You can request a php script on server1 from javascript code hosted
on server2 that doesn't need to have any scripting capabilities. I use
this design to syndicate news to another web sites and provide a
simple installation procedure. Is this what you are looking for?

Regards.

Clarification of Question by springshopping-ga on 04 Jan 2003 08:22 PST
Hello all!

Thank you for your great comments. However I have limited access on
www.server2.com; I can only insert a javascript.

I have created an info - page for you to get a more detailed view on
my subject. Please check this page. :-)

http://www.dorra.net/gainfo/

Thank you,
springshopping
Answer  
There is no answer at this time.

Comments  
Subject: Re: Is it possible to get Data into a JavaScript Code by calling a CGI?
From: hammer-ga on 31 Dec 2002 08:41 PST
 
Your pages do not appear to be at the links you provide. You may want
to check the addresses and clarify your question.

- Hammer
Subject: Re: Is it possible to get Data into a JavaScript Code by calling a CGI?
From: springshopping-ga on 31 Dec 2002 10:08 PST
 
No, www.server1.com and www.server2.com are only examples. The real
application is way to complex to describe it here.

The simple way to explain my question is:

I want modify my design on server2 based on an cgi-request at server1.

I want to make this request via javascript, because i donĀ“t want to
change the code of the pages on server2 in general.

I want to be tricky and just implement some javascipt code on the
pages of server2.

More questions?!

Best regards,
springsshopping
Subject: Re: Is it possible to get Data into a JavaScript Code by calling a CGI?
From: triniman-ga on 01 Jan 2003 16:59 PST
 
Well, I'm not sure what data you want passed, but here's a little
trick:

Javascript can grab data from a cgi script by setting the "src"
attribute
of an image to be the output of a cgi script.

ie. 
An image on server2.com with src "/server1.com/cgi.php?x=1&y=2" can
output an transparent 2 x 1 pixel gif image.

After that.. well perhaps the dimensions of the image generated can be
of some use - they can be checked in javascript as well via the
"width" and "height" image attributes.

If I can think of anything else, I'll let you know.

Email me jason.NOSPAM@quickbrowse.com
Subject: Re: Is it possible to get Data into a JavaScript Code by calling a CGI?
From: shivakumar-ga on 02 Jan 2003 19:53 PST
 
Yes it is possible to call a javascript from a CGI output.

but the older version of netscape (starting from 4.04 and above) and
internet explorer(starting from  3.x and above) will not accept it
where you can use the noscript tag to put your data.

A sample of how to call it would be like this 
<script  language="JavaScript"  type="text/JavaScript"
src="http://www.server1.com/cgi.php"></script>

and the content type of the CGI should be "text/JavaScript" 
however  "text/html" will not make much of a diffrence.

Regards,
Sivakumar.
Subject: Re: Is it possible to get Data into a JavaScript Code by calling a CGI?
From: jgarrigu-ga on 03 Jan 2003 22:14 PST
 
I created an example for you.
See if this is heading in the right direction.

http://dvneo.com/server2form.html

-Jim
Subject: Re: Is it possible to get Data into a JavaScript Code by calling a CGI?
From: cwrl-ga on 07 Jan 2003 09:33 PST
 
It sounds to me like you want to request some data from the
CGI script using HTTP, and store the result in a JavaScript
variable? I believe that this is possible, in newer browsers,
using the XMLHTTPRequest object; cf.

  http://jibbering.com/2002/4/httprequest.html

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy