fixed runtime errors with ajax calls