'Ajax handler.
Args:
dispatch: string request slug
data: dict request get parameters
Returns:
json string'

def handle_ajax(self, dispatch, data):

    if (dispatch == 'submit'):
        if self.submitted:
            return json.dumps({'status': 'fail', 'error': 'You    have    already    posted    your    data.'})
        raw_student_words = data.getall('student_words[]')
        student_words = filter(None, map(self.good_word, raw_student_words))
        self.student_words = student_words
        temp_all_words = self.all_words
        self.submitted = True
        for word in self.student_words:
            temp_all_words[word] = (temp_all_words.get(word, 0) + 1)
        self.top_words = self.top_dict(temp_all_words, self.num_top_words)
        self.all_words = temp_all_words
        return self.get_state()
    elif (dispatch == 'get_state'):
        return self.get_state()
    else:
        return json.dumps({'status': 'fail', 'error': 'Unknown    Command!'})
