setting up ajax call and fixing some syntax errors