secret
yko / t
Created

  • Download Gist
t
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#!/usr/bin/env perl
use warnings;
use 5.014;
use utf8;
use Mojolicious::Lite;
 
get '/eingabe' => sub {
my $self = shift;
$self->render( 'eingabe' );
};
 
get '/search_db' => sub {
my $self = shift;
$self->render( json => [ 'John', 'Jack', 'Joe', 'Lisa', 'Barbara' ] );
};
 
app->start;
 
__DATA__
@@ eingabe.html.ep
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
<script type="text/javascript">
$( document ).ready( function() {
$( "#name" ).autocomplete({
source: '/search_db',
minLength: 2
});
});
</script>
</head>
<body>
<form>
<table>
<tr><td>Name:</td><td><input type="text"
id="name" name="name" /></td></tr>
</table><br />
<input type="submit" value="OK"/>
</form>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.