Write to file question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • von

    Write to file question

    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.co m/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.co m/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.co m/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



  • RobB

    #2
    Re: Write to file question

    von wrote:[color=blue]
    > 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[/color]
    the data[color=blue]
    > to a Perl script:
    >
    > var i=new Image();
    > i.src="http://www.mydomain.co m/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.co m/cgi-bin/write.pl?" + "test";
    >
    > Then it returns the word "test" - so I know the Perl script is[/color]
    working.[color=blue]
    >
    > When I try this:
    >
    > var i=new Image();
    > i.src="http://www.mydomain.co m/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[/color]

    Not quite clear where that "Object" is coming from...but this is
    unclear:
    [color=blue]
    > 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>[/color]

    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.getEle mentById('Data1 ')
    && (txt = el.firstChild))
    {
    var i = new Image;
    i.src = 'http://www.mydomain.co m/cgi-bin/write.pl?' + txt.nodeValue;
    }

    Comment

    Working...