Refactor jquery/ajax code, modify task form