Added a JSON API and AJAX calls.