pulled out ajax call into a submit function