I have a form - textarea (named su
) and submit button.
When the form is submitted, I need to
- run a PHP script without refreshing/leaving page
- "echo" or somehow print a return on the screen
I'm pretty sure this works via some kind of ajax request thing. but I have no idea how.
Like I said I'm uneducated with ajax or java. A quick example would be wonderful.
Simple , that is what is called AJAX. The solution is more of Javascript, than PHP.
Using Jquery, you can do it with a simple function call:
Does the trick.
If your just now getting into ajax, PHP, and JQuery I would highly suggest using firefox and installing Firebug. Learn to use it and it will tell you all sorts of great things. There is not enough space to tell you everything it does, but it is ,at this point, one of my best debugging tools. Learn it, Love it and good luck.
It is usually best to use a Javascript library for doing AJAX.
See jQuery.get() for one way to send a request to a PHP web page using the jQuery library. You can have your PHP page output Javascript to be executed, or output plain text or data.