First, WordPress has a built-in way to handle AJAX requests, you should read this page and use that method instead.
The issue with your method is that you’re POST
ing the name
var. name
is a WordPress query var, and is causing WordPress to query for a page with slug John
. Always prefix your vars with a unique string to avoid these problems.