1 <% encode_json($return) %>\
4 local $SIG{__DIE__}; #disable Mason error trap
8 my $conf = new FS::Conf;
10 # figure out the prefix
12 foreach my $name ($cgi->param) {
13 if ($name =~ /^(\w*)address1$/) {
18 die "no address1 field in location" if !defined($pre);
20 # gather relevant fields
21 my %old = ( map { $_ => scalar($cgi->param($pre . $_)) }
22 qw( company address1 address2 city state zip country )
25 my $cache = eval { FS::GeocodeCache->standardize(\%old) };
27 # don't do set_censustract here, though censustract may be set by now
29 # give the fields their prefixed names back
30 # except always name the error string 'error'
31 my $error = delete($cache->{'error'}) || '';
35 map { $pre.$_, $cache->get($_) } keys %$cache
38 foreach ( qw(address1 address2 city state zip country) ) {
39 if ( $new{$pre.$_} ne $old{$pre.$_} ) {
45 # refold this to make it acceptable to jquery
46 #my $return = [ map { { name => $_, value => $new{$_} } } keys %new ];
48 warn "result:\n".encode_json($return) if $DEBUG;
50 $r->content_type('application/json');