Let $(x,y,z)$ and $(x',y',z')$ be two points in space. Let the distance between them be $r$. Also let:
$x-x'=\xi$
$y-y'=\eta$
$z-z'=\zeta$
Since $(x,y,z)$ and $(x',y',z')$ are two separate points, changing only the point $(x,y,z)$ will not change the point $(x',y',z')$. Therefore:
$\dfrac{\partial x'}{\partial x}=\dfrac{\partial x}{\partial x'}=0$
Then:
$\dfrac{\partial r}{\partial x}=\dfrac{dr}{dr^2}\dfrac{\partial r^2}{\partial x}=\dfrac{1}{2r}\dfrac{\partial(\xi^2 +\eta^2 +\zeta^2)}{\partial \xi}\dfrac{\partial \xi}{\partial x}=\dfrac{1}{2r}.2 \xi.\dfrac{\partial(x-x')}{\partial x}=\dfrac{\xi}{r}$
and
$\dfrac{\partial r}{\partial x'}=\dfrac{dr}{dr^2}\dfrac{\partial r^2}{\partial x'}=\dfrac{1}{2r}\dfrac{\partial(\xi^2 +\eta^2 +\zeta^2)}{\partial \xi}\dfrac{\partial \xi}{\partial x'}=\dfrac{1}{2r}.2 \xi.\dfrac{\partial(x-x')}{\partial x'}=-\dfrac{\xi}{r}$
Now let's find $\dfrac{\partial r}{\partial x'}$ by another way using chain rule:
$\dfrac{\partial r}{\partial x'}=\dfrac{\partial r}{\partial x}\dfrac{\partial x}{\partial x'}=\dfrac{\xi}{r}.0=0$
I guess I am getting different answers because there is something wrong in the application of chain rule here. Can someone explain why am I getting different answers?
The thing you have to bear in mind about partial derivatives is they assume something is held constant, but $\partial_u v\partial_v w = \partial_u w$ is only guaranteed when the partial derivatives on the left-hand side hold the same things constant. Define $\alpha:=\left(\xi,\,\eta,\,\zeta\right)$. In your first calculation, you show $(\partial_{x'}x)_{\alpha}=0$, where the subscript indicates what's held constant. But in your final calculation, you try $(\partial_{x'}r)_{?}=(\partial_x r)_{x'}(\partial_{x'}x)_\alpha$, about which nothing follows from the chain rule.