Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: AJAX'ifying a web form and dynamic server validation through Perl

by mattk (Pilgrim)
on Sep 20, 2007 at 12:15 UTC ( #640101=note: print w/replies, xml ) Need Help??


in reply to AJAX'ifying a web form and dynamic server validation through Perl

I recently started using ExtJS, with CGI::Application and JSON. It works nicely, and abstracts away a lot of the pain of cross-browser compatibility, though the large file size can be a problem (there are other, lighter toolkits that may better serve your purpose). Here's a 30 second example that gets you AJAX style updates:
callbackFunction = function(options, success, response) { if (success === true) { var data = Ext.decode(response.responseText); doSomething(data); // or Ext.get('contents-div').dom.innerHTML = response.responseText; } else { Ext.MessageBox.alert('Error', 'Something blew up.'); } } Ext.Ajax.request({ url: '/path/to/cgi', callback: callbackFunction, params: { rm: 'ajax_function' } });
The Perl part, assuming you've tagged this sub as a runmode:
sub ajax_function { my ($self) = @_; my $data = doStuff(); # or you could return HTML return $self->{json}->objToJson($data); }
It has other cool stuff built in, like the ability to automatically generate fields and labels for a form, and bind the validation and submission to callback functions, visual effects, data stores and interfaces for all different kinds of sources... it actually got me interested in learning JS. Pretty cool stuff.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://640101]
help
Chatterbox?
shmem doesn't have mp3info, but mp3info2 - which is a perl script ;-)
[marioroy]: my @music_times = qx(find \$HOME/Music/ Albums/ -type f -iname '*.mp3' -exec mp3info -p "%S\\\n" {} \\;);
[marioroy]: might need 2 or 3 backslash for \n. Also \\;
[Lady_Aleena]: shmem, there is MP3::Info/
[Discipulus]: too much complex qx when you know perl are better to avoid
[marioroy]: might need to backslash \'*.mp3\'
[marioroy]: It's a quoting issue inside qx. It's File::Find or qx. LA chooses qx. Almost there.
[marioroy]: Also \"%S\\\n\" oh my, not fun.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2017-04-23 21:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.