I have a jQuery variable. It’s a text string. I want to create a .txt file on the server, then write that string to the text file.
How do I trigger this without reloading the page? I know PHP will have to get involved somewhere…
My attempts to do this with $.ajax(); haven’t worked.
You could pass this variable to a php script:
or if you prefer using $.ajax:
and then inside your
foo.phpscript read the data from$_POST["data"]and save the contents to some file on the server.