responds to ajax

ineptly coded. suggestions welcome.