What I am telling you is that you can't show anything to a user while the page is still on the server where the php is being parsed.
Ajax calls and javascript is executed client side and can't do anything until the page is loaded (After all the php is executed).
So I don't think you should use Ajax in this case, I think you should just let the php finish and then return the whole page.