ajax_demo: removed redundancy in code