- or download this
<script type="text/javascript">
$(function(){
$(".ethnicity").click(function(){
...
$.getJSON('menu.cgi',
{ rm:'g', ethnicity:$(this).val() },
....
- or download this
my $stmt = qq~SELECT id, entrees FROM menu WHERE ethnicity = ?~;
my $entrees = $self->dbh->selectall_arrayref($stmt, {Slice => {}}, $se
+lf->query->param('ethnicity'));
return $self->json_body( $entrees); #using CGI::App::Plugin::JSON
- or download this
function(result){
// returns: [{"entrees":"Lasagna","id":"1"},{"entrees":"Spaghetti","id
+":"2"},{"entrees":"Pizza","id":"3"}]
...
}
$('#entree').html(options);
- or download this
$('#menu').submit(function() {
...
});
return false;
});
- or download this
sub save_form {
my $self = shift;
...
my $result = [{ 'messages' => $self->param('error_list') }];
return $self->json_body( $result );
}
- or download this
$.ajax({
type: "POST",
...
}
});
- or download this
$self->record();
...
my $result = [{ 'messages' => $self->param('success_list') }];
return $self->json_body( $result);
- or download this
if (success) {
$('#'+form).resetForm();//jquery.form.js feature
...
$('#'+msgdiv).css('display','block'); //display the success
$('#'+msgdiv).append(success); // div and message
}
- or download this
<!--include common header for all pages -->
<tmpl_include header.tmpl>
...
</script>
<!--pull in a standard footer for all pages -->
<tmpl_include footer.tmpl>
- or download this
//called in HTML <head> with:
//<script type="text/javascript" src="forms.js"></script>
...
$('#'+msgdiv).append(success); // div and message
}
}
- or download this
#--- Get entrees on the fly
sub get_entrees {
...
return $self->json_body( $entrees);
}
- or download this
use CGI::Application::Plugin::DBH (qw/dbh_config dbh/);
use CGI::Application::Plugin::JSON ':all';
...
$self->dbh->do( $stmt, undef, values %sql);
+
$self->param('success_list' => [{'success' => 'Record added'}]);
}
- or download this
use Email::Valid;
...
return $value;
}
}
- or download this
.form {
float: left;
...
color: green;
background: url(/images/success.png) no-repeat 5px;
}