The Ax-Grothendieck Theorem is far more general than for the case of a morphism from affine space to itself.  Here is a sketch of the proof of the result in that case.  The basic ideas are similar to those in Jouanolou's Bertini-theory book used to simplify the proof of the Quillen-Suslin Theorem. 

<B>Edit. I cannot complete my proof. </B> The result is wrong, as shown by the accepted answer by user @pinaki.  The problem with my proof is that the divisor $\text{Zero}(f)$ I need in the target must simultaneously be transverse to the branch divisor and contain the image of the singular locus of the integral closure variety $X$.  Those two conditions are mutually exclusive.  I am keeping the post below because it proves the result for $n=1$, and it highlights the issue for $n>2$.


<B>Lemma 1.</B> For a field $k$, every $k$-subalgebra $R$ of $k[x]$ that strictly contains $k$ is a finite type $k$-algebra, and $k[x]$ is a finitely generated $R$-module.  Thus, every nonconstant, dominant $k$-morphism to an integral affine $k$-scheme from $\mathbb{A}^1_k$ is finite, hence surjective.

<B>Proof.</B> This is a variant of the proof of Noether's bound in invariant theory.
Let $m(x)\in R$ be any nonconstant monic element.  Then the $k$-subalgebra $S$ of $R$ generated by $m(x)$ is a finite type $k$-algebra.  Moreover, the element $x\in k[x]$ satisfies a monic polynomial in $t$ with coefficients in $S$, namely $m(t) - m(x)$.  

Thus $k[x]$ is a finitely generated $S$-module, and $R$ is an $S$-submodule.  Since $S$ is a finite type $k$-algebra, hence Noetherian by the Hilbert Basis Theorem, the $S$-submodule $R$ is finitely generated.  Hence $R$ is a finite type $k$-algebra, and the finitely generated $S$-module $k[x]$ is also finitely generated as an $R$-module. <B>QED</B>
 
<B>Lemma 2.</B> For a field $k$, for every affine, dominant, quasi-finite $k$-morphism $p:U\to Y$ between normal, integral, finite type $k$-schemes, there is a factorization of $p$ as $i:U\to X$ composed with $\overline{p}:X\to Y$, where $i$ is a dense open immersion, and $\overline{p}$ is a finite $k$-morphism between normal, integral, finite type $k$-schemes.

<B>Proof.</B> Of course this follows quickly from Grothendieck's version of Zariski's Main Theorem.  It also follows from the Noether Normalization Theorem: let $X$ be the integral closure of $Y$ in the function field of $U$. <B> QED</B>

Denote by $D$ the closed complement $X\setminus U$ with its reduced structure.

<B>Lemma 3.</B> The morphism $p$ is not finite if and only if $D$ is a nonempty divisor in $X$.

<B>Proof.</B> Of course the statement that $p$ is finite is equivalent to the statement that $D$ is empty.  
Since $X$ is normal and affine over $Y$, the (reduced) closed complement $D=X\setminus U$ of the $Y$-affine scheme $U$ is either empty or has pure codimension $1$.  <B> QED</B>

<B>Hypothesis 4.</B>
The non-smooth locus of each $k$-scheme $U$ and $Y$ has irreducible components of codimension $\geq 2$.

Since $U$ and $Y$ are normal, this follows from Serre's Criterion for Normality if the characteristic is $0$.  Of course in the case of interest, when $U$ and $Y$ are each isomorphic to affine space, the hypothesis holds.

By construction of $X$, also the non-smooth locus has codimension $\geq 2$.  Thus, there is a closed subscheme $Z\subset Y$ all of whose irreducible components have codimension $\geq 2$ such that $Y\setminus Z$, and the preimage $\overline{p}^{\text{pre}}(Y\setminus Z)$ are smooth $k$-schemes, and the intersection of these smooth $k$-schemes with $D$ is reduced (possibly reducible).  In particular, if $D$ is not empty, then $D$ is a Cartier divisor on the open $\overline{p}^{\text{pre}}(Y\setminus Z)$.  Since $X$ is finite over $Y$, this Cartier divisor becomes principal, say the divisor of $g$, on all preimage open subsets $\overline{p}^{\text{pre}}(V)$ for $V$ sufficiently small Zariski open subsets in $Y\setminus Z$.  In particular, if $V$ equals $D(f)$, then the ring extension $k[Y][f^{-1}] \to k[U][f^{-1}]$ contains $k[X][f^{-1},g^{-1}]$ as a subring, i.e., $g$ is already invertible in $k[U][f^{-1}]$.  However, when $k[U]$ equals $k[x_1,\dots,x_n]$, we know what are all the invertible elements in $k[U][f^{-1}]$.
 
The argument from here on uses a Bertini result.  I am trying to write this up now.


<B>Edit.</B>  The Bertini result that I needed is wrong; see the explanation above.