LanX has asked for the wisdom of the Perl Monks concerning the following question:
I'm having an issue with fetching web-content via webperl which is probably related to asynchronism. (final goal: to dynamically load and install non-bundled Perl modules)
This code works when included into the democode page
use warnings; use strict; use Data::Dumper; use WebPerl qw/js/; my $fetch =<<'__JS__'; var req = new XMLHttpRequest(); req.open('GET', 'https://webperl.zero-g.net/', false); req.send(null); if(req.status == 200) (req.responseText); __JS__ print Dumper js($fetch);
please note that because of the same origin policy I can only access data from the same server.
After installing webperl and plack locally I can run it under localhost:5000
Now I copied webperl_demo.html to a new page and included the follwing JS-code
which is able to fetch (for demonstration) the included emperl.js<script> var req = new XMLHttpRequest(); req.open('GET', 'http://localhost:5000/emperl.js', false); req.send(null); if(req.status == 200) alert(req.responseText); </script>
BUT running the following webperl code not only fails, but blocks the page
<script type="text/perl"> use warnings; use strict; use Data::Dumper; use WebPerl qw/js/; my $fetch = << '__JS__' ; var req = new XMLHttpRequest(); req.open('GET', 'http://localhost:5000/emperl.js', false); req.send(null); if(req.status == 200) (req.responseText); __JS__ print Dumper js($fetch); </script>
What am I missing?
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: webperl: fetching data over the web
by haukex (Archbishop) on Nov 08, 2018 at 15:15 UTC | |
by LanX (Saint) on Nov 08, 2018 at 15:29 UTC | |
by haukex (Archbishop) on Nov 08, 2018 at 15:39 UTC | |
by LanX (Saint) on Nov 08, 2018 at 15:46 UTC | |
Re: webperl: fetching data over the web
by LanX (Saint) on Nov 08, 2018 at 15:21 UTC | |
by haukex (Archbishop) on Nov 08, 2018 at 15:25 UTC | |
by LanX (Saint) on Nov 08, 2018 at 15:33 UTC | |
by haukex (Archbishop) on Nov 08, 2018 at 15:48 UTC | |
by LanX (Saint) on Nov 08, 2018 at 17:39 UTC | |
| |
Re: webperl: fetching data over the web
by LanX (Saint) on Nov 09, 2018 at 15:11 UTC |