in reply to jquery scripts

A templating system can be used to construct a Perl-friendly string containing the necessary data ... but also, this is essentially what the JSON format already is.   (Originally, the idea behind JSON was that a JavaScript client could simply eval the string, but those innocent days are gone now.)

It is impossible for you to refer to a Perl variable, such as $mydata, in the web-page text that you send to the client, because the client has no idea where the web-page came from and has no access at all to the (Perl) software that may have produced it.   Directly or indirectly, it must see a JavaScript statement that it can correctly parse and execute.   The (Perl) server must use the content of its (Perl) variable to generate syntactically-correct and executable JavaScript literals.

Replies are listed 'Best First'.
Re^2: jquery scripts
by marto (Cardinal) on Oct 13, 2015 at 08:49 UTC

    "It is impossible for you to refer to a Perl variable, such as $mydata, in the web-page text that you send to the client, because the client has no idea where the web-page came from and has no access at all to the (Perl) software that may have produced it."

    Proving once again that you have no idea what you're talking about. This is possible and quite common. You replied after other users provided working example code (an alien concept to you I know) that shows how to achieve this.

      in the web-page text that you send to the client

      That having been clarified, I don't think that's what the OP was after anyway, so sundial's answer is still essentially useless.

Re^2: jquery scripts
by hermit23 (Initiate) on Oct 13, 2015 at 08:19 UTC

    dear Brothers,

    Thank you very much for your further comments on using jquery scripts. I shall need to go away and meditate on templating systems.