adds ajax query and handling to js