Updated course form JS with proper handling of 404 API calls