Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

PERL CGI HTML JAVASCRIPT APACHE PROBLEM

by MONKTROOPER (Initiate)
on Apr 22, 2015 at 20:54 UTC ( [id://1124305]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks i have a simple implementation using HTML PERL AND JAVASCRIPT , runing with xampp apache web server , the code are the following:

HTML PART

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>THIS IS A PERL SCRIPT TEST</h1>
<p>WE WILL EXECUTE PERL SCRIPT</p>
<br>
<a href="http://localhost/cgi-bin/prueba3.cgi">
EXECUTESCRIPT</a>
</body>
</html>

prueba.cgi

#!"C:\xampp\perl\bin\perl.exe"
use strict;
use warnings;
use CGI qw{ :standard };
use CGI::Carp qw{ fatalsToBrowser };
print "Content-type: text/html\n\n";
print"<head>";
print "<title>PERL</title>";
print qq{<script src="basico.js">};
print "</script>";
print"</head>";
print "<body>\n";
print "<h1>READY TO TEST A JAVASCRIPT FROM
PERL</h1>";
print "<p>THE SCRIPT IS:</p>";
print qq{<input type="button" onclick="popup()"
value="EXECUTE SCRIPT!">};
print"</body>\n";
print"</html>";

basico.js

function popup() {
alert("a javascript is running")}

When its runing and click in the EXECUTE SCRIPT! button to call javascript , the browser doesnt respond, using the developer browser tools i can read the message: Failed to load resource: the server responded with a status of 500 (Internal Server Error), could anyone help me? thanks a lot

Replies are listed 'Best First'.
Re: PERL CGI HTML JAVASCRIPT APACHE PROBLEM
by kcott (Archbishop) on Apr 23, 2015 at 05:18 UTC

    G'day MONKTROOPER,

    "<ahref="http://localhost/cgibin/prueba3.cgi"> ..."

    You have a typo in your HTML code. The element 'a' and its attribute 'href' need a space between them. Your browser knows nothing of this new-fangled element 'ahref' and so ignores it, hence the lack of a response.

    s/ahref/a href/

    I also notice you have a directory called 'cgibin'. That's usually spelled with a hyphen: 'cgi-bin'. You may want to check your spelling.

    -- Ken

      Hi kcott i chek it ,thanks
Re: PERL CGI HTML JAVASCRIPT APACHE PROBLEM
by afoken (Chancellor) on Apr 22, 2015 at 21:12 UTC
    the server responded with a status of 500 (Internal Server Error)

    Details are in the error log of the web server.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Hi afoken i'll check error log
Re: PERL CGI HTML JAVASCRIPT APACHE PROBLEM
by bitingduck (Chaplain) on Apr 23, 2015 at 05:22 UTC

    To expand a little on afoken's reply - when I'm debugging things that generate errors that get logged somewhere, I often will have an extra terminal window open and do a "tail -f /etc/log/error.log" where you replace the "/etc/log/error.log" part with the path to the appropriate server log on your system. This will display the log in real time so you can correlate the log details to exactly how you triggered it.

      thanks for advice ill try it
        Thanks to all , the problem was the location of the javascript file, the solution was put it in the htdocs folder
        C:\xampp\htdocs
        and change the line in the perl's scrip who call the .js file
        print qq{<script src="http://localhost/basico.js">};
        finally all works fine!
Re: PERL CGI HTML JAVASCRIPT APACHE PROBLEM
by NetWallah (Canon) on Apr 23, 2015 at 00:30 UTC
    Try this checklist: Troubleshooting Perl CGI scripts.

            "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams

Re: PERL CGI HTML JAVASCRIPT APACHE PROBLEM
by Anonymous Monk on Apr 22, 2015 at 22:56 UTC
    use absolute urls before you try using relative urls ... just like pathnames, don't try relative paths until you figure out how absolute paths work
      i tried but shows another error : Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

        i tried but shows another error : ...

        what did you try?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1124305]
Approved by NetWallah
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-04-18 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found