Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use Ajax, perl and JSON easy together?

I am trying to make a webpage with Ajax.

Example:

  1. I create a Perl/CGU file that triggers a simple post;

    File: ..test.cgi?name=Thomas

    Text back: Your name is Thomas!

  2. I create a html file that can use the post, but then the page have to reload. I use text input and a button.

How can I use Ajax, Perl and JSON easy together? This is how it should work together, but how?

Html + Ajax/JavaScript CALL Perl + "JSON-perl-string" RETURN-TO Ajax CONVERT-JSON -> Html

like image 832
jeje1983 Avatar asked Nov 30 '22 20:11

jeje1983


1 Answers

For JSON try the CPAN JSON module.

For using the XMLHttpRequest I recommend these wonderful tutorials from IBM.

Mastering Ajax, Part 1: Introduction to Ajax

The two articles you'll probably be most interested in are these two:

Mastering Ajax, Part 10: Using JSON for data transfer

Mastering Ajax, Part 11: JSON on the server side

You can get the entire 11 Part series using this search link.

like image 117
Robert S. Barnes Avatar answered Dec 04 '22 08:12

Robert S. Barnes