Throwing Errors In Javascript Call