client side hide appending a server side file (without leave the current page)

client side hide appending a server side file (without leave the current page)

I can use file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
to add a few lines of text to a server side file
and I can post from client side to a php file to do the actual append lines.
But I have had no luck on client side without leaving the current page/position.
I just want to add a javascript variable string to file.
I have tried different ajax scripts that I have found but each had a different problem.
Trying to keep it simple.
Thanks,
Ray