By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,945 Members | 1,540 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,945 IT Pros & Developers. It's quick & easy.

Write to file question

P: n/a
von
I am trying to write a single piece of data (that is generated from a
Javascript) to a text file on my server via a Perl script.

The Javascript is setup so that I can display the required data on my
website using the following HTML:

<span name='Data1' class='data1'></span>

But I need it sent to a text file. :(

I have tried using the following code (thanks to saxifrax) to send the data
to a Perl script:

var i=new Image();
i.src="http://www.mydomain.com/cgi-bin/write.pl?" + span;

But it doesn't return anything.

If I test my Perl script with this:

var i=new Image();
i.src="http://www.mydomain.com/cgi-bin/write.pl?" + "test";

Then it returns the word "test" - so I know the Perl script is working.

When I try this:

var i=new Image();
i.src="http://www.mydomain.com/cgi-bin/write.pl?" + allSpans;

Then it returns "Object" - whatever that means.
Anyone have any advice on how to get the data sent to my Perl file?

Thanks :)

-Von

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
von wrote:
I am trying to write a single piece of data (that is generated from a
Javascript) to a text file on my server via a Perl script.

The Javascript is setup so that I can display the required data on my
website using the following HTML:

<span name='Data1' class='data1'></span>

But I need it sent to a text file. :(

I have tried using the following code (thanks to saxifrax) to send the data to a Perl script:

var i=new Image();
i.src="http://www.mydomain.com/cgi-bin/write.pl?" + span;

But it doesn't return anything.

If I test my Perl script with this:

var i=new Image();
i.src="http://www.mydomain.com/cgi-bin/write.pl?" + "test";

Then it returns the word "test" - so I know the Perl script is working.
When I try this:

var i=new Image();
i.src="http://www.mydomain.com/cgi-bin/write.pl?" + allSpans;

Then it returns "Object" - whatever that means.
Anyone have any advice on how to get the data sent to my Perl file?

Thanks :)

-Von
Not quite clear where that "Object" is coming from...but this is
unclear:
The Javascript is setup so that I can display the required data on my
website using the following HTML:

<span name='Data1' class='data1'></span>


We can't see how the JS is 'setup' - a key factor. Is a text string
being displayed within that span? If so, you can give it an id
(="Data1") - spans don't take names as attributes - and use:

var el, txt;
if (el = document.getElementById('Data1')
&& (txt = el.firstChild))
{
var i = new Image;
i.src = 'http://www.mydomain.com/cgi-bin/write.pl?' + txt.nodeValue;
}

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.