Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Vincent Asta
Vincent Asta
2,330 Points

Can I use JavaScript to interact with Perl on a web server?

Is it possible to have a web server execute a Perl script using a js variable captured from a prompt to a user?

For example: 1.) Web page (with .js file) is loaded on end user's machine 2.) .js prompts user for a variable 3.) variable 'blah' is captured 4.) Perl script is then executed with blah passed to it 5.) The result from that Perl script is returned to the web page for the user to view (alert, another page, etc.)

I'm hoping this makes some sense, not sure if I am formulating the question correctly, or if there is more info I can provide which would be helpful.

I just wanted to know if I am 'on the right track' so-to-speak, or if I should go down another track, i.e. PHP, RoR, etc.

1 Answer

Chris Shaw
Chris Shaw
26,650 Points

Hi Vincent,

First off just a quick FYI that w/ is short for without, I've updated your posts title so it's not confusing.

To answer your question yes you can absolutely use JavaScript to make requests to any back end language such as perl, in your JavaScript you need to make what's known as an XMLHttpRequest which built into all browsers the same way as of IE9.

I'm typing this on my mobile so it's a bit hard to get some running examples but if you see the below link it has a lot of useful information until I get into work.


Vincent Asta
Vincent Asta
2,330 Points

Hello Chris,

I updated the title of my post to make it more clear, thanks for the feedback.

Thanks for the reply on usage of JavaScript. I'll check this link out to see what is behind making this work. If you did come across a working example, I would appreciate it very much.

Slightly off-topic, but w/ is short for 'with', w/o is short for without... :)