Fixing the AJAX function location

This bug addresses the incorrect location of the AJAX function call in api.py and moves it to the correct location in views.py
It also standardizes the AJAX JSON function to use a generic Django class instead of a function.

Change-Id: I445ca58d1e05187c9d05fdb6814039c69543324c
Fixes: bug #1201980
Merge "Fixing the AJAX function location"