kruegerm has asked for the wisdom of the Perl Monks concerning the following question:

I have written a perl script I can access from a URL: https://hostname/myweb/myScript.pl?id=1234&stg=13 I get the proper results using the URL

In javascript/jscript, I have tried loading the script ($('#element').load()) - I've tried full ajax calls within a function:

$.ajax({ url: '/myweb/myScript.pl', type: 'post', data: { 'id' : '1234', 'stg' : '13' } });

Replies are listed 'Best First'.
Re: Need help calling perl from javascript
by Your Mother (Archbishop) on Oct 17, 2019 at 19:21 UTC

    If you were using a standard engine like CGI, that POST would/should work fine. Sounds from the SO thread like you’re processing params yourself. A somewhat serious mistake, I argue. That said, .serialize() in jquery will probably construct the GET query string you want. Something like (untested!)–

    $.ajax({ url: "/myweb/myScript.pl?" + $("#yourForm").serialize() });

    An SSCCE will always get you better answers on every forum.

Re: Need help calling perl from javascript
by choroba (Cardinal) on Oct 17, 2019 at 19:08 UTC
    Crossposted to StackOverflow. It's considered polite to inform about crossposting to protect people not visiting both sites from unnecessary work of hacking a solution to a problem already solved at the other end of the internet.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: Need help calling perl from javascript
by Anonymous Monk on Oct 17, 2019 at 23:24 UTC
    Use sub DebugCGI to figure out what gets sent, adjust your program accordingly