How to make sense of the inverse image of a Weil divisor? I was reading Hartshorne's proof that $Cl(X \times \mathbb A^n)=Cl(X)$. He defines the map $Cl(X) \to Cl(X \times A^n)$ by mapping the class of a prime divisor $D$ of $X$ to $p^{-1}(D)$ where $p:X \times A^n \to X$ the projection.
I am not sure I understand what $p^{-1}(D)$ means. Is it just the scheme theoretic inverse of $D$ ie $D \times_X (X \times_k A^n)$? would that be the same as $D \times_k A^n$ as intuition would suggest?
Finally, does this generalizes to an arbitrary morphism $f:Z \to Y$?
 A: Yes, it is probably easiest to interpret $p^{-1}(D)$ as $D \times \mathbb A^n$ if $D$ is an irred. (i.e. prime) Weil divisor.

In general you have to be careful when defining the preimage of a divisor.  If $D$ 
is a Cartier divisor, then associated to its linear equivalence class is an invertible sheaf $\mathcal O(D)$, and you can define the preimage of $D$ (up to linear equivalence) under a morphism $f: Z \to X$ as (the linear equivalence class of Cartier divisors associated to) $f^*\mathcal O(D)$.
If $D$ is an actual effective Cartier divisor, cut out by the regular section
$s \in \mathcal O(D)$ (as in this discussion), then we can attempt to define the pull-back of $D$ 
via $f$ as being the Cartier divisor cut out by the section $f^*s \in f^*\mathcal O(D)$.  But this only makes sense if $f^*s$ is again regular, i.e. doesn't vanish
on any component (or any embedded component, in the non-reduced context) of $Z$.
(Think about the cases when $Z \to X$ is $\{0\} \hookrightarrow \mathcal A^1$,
and $D_1$ is the divisor $(0)$ and $D_2$ the divisor $(1)$.)

In many contexts (e.g. smooth varieties) Cartier and Weil divisors are the same,
and so the above discussion already gives quite a lot of information about your
general question.
In contexts where Weil and Cartier divisors differ, you have to be even more careful with Cartier divisors, since there is only the direct geometry available --- you can't sneakily convert the question to one about invertible sheaves (which are very flexible and easy to move around).
Basically, if you have an effective Weil divisor $D$, with ideal sheaf $\mathcal I_D \subset \mathcal O_X$, and $f: Z \to X$, you can look at the ideal sheaf of $\mathcal O_Z$ generated by $f^{-1}\mathcal I_D$ (which is a sub sheaf of $\mathcal O_Z$).  If this ideal does not cut out any components of $Z$, then it is reasonable to define the codimension one part of the zero locus of this ideal as the pullback of $D$ as a Weil divisor.  
But whether or not my assumption holds (i.e. whether or not this ideal actually
does cut out any components of $Z$) will depend a lot on the situation.  You might
want to think about what happens if you had a smooth (or more generally flat)
morphism, and then compare with what happens when you have closed immersions
(where again, the examples of mapping a point into $\mathbb A^1$, as above, are already instructive).
