use AJAX API instead of inline JS