07 Nov
2012

php icon grafxflow

Passing data between jQuery and PHP

Here is a basic example of passing form data to a PHP file via jQuery and then passing data back to jQuery from the PHP file.

1. Lets start by creating a basic form. You will notice I have noted out the normal submit input, because I prefer using hyperlinks for easier CSS styling, and since the hyperlink has to activate the javascript I have left the URL link empty.

2. Next is the javascript which includes jQuery. The code is adding an event to detect when the submit hyperlink (with the title “submit_button”) has been pressed.

3. Finally the external PHP script returns the posted value back to the jQuery function.

Here is the html form page in full.

avatar

Written by me@grafxflow

I am a freelance designer and developer of all things web - from CSS3 bootstrap responsive layouts through to WordPress and MVC CodeIgniter. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!

Follow grafxflow on twitter Follow grafxflow on github Follow grafxflow on google+

No Comments on "Passing data between jQuery and PHP"

smart search