Sending data to PHP
GET and POST are the two most frequently used methods for accessing pages. In the first recipe you learned to make requests using GET method.
This recipe will make use of jQuery's $.post()
method to retrieve data from a PHP script. We will see a simple example where we will fill some data in a form and the data will be sent to PHP using the POST method. Sent data will be processed by PHP and then displayed in the browser.
Getting ready
Create a new directory named Recipe4
under the chapter2
directory.
How to do it...
Create a file named
index.html
in the newly createdRecipe4
directory. In this recipe, we will use the same form that we created in the second recipe (Creating query string automatically for all form elements) of this chapter. So write the HTML that will create a form with multiple controls.<html> <head> <title>Sending data through post</title> <style type="text/css"> ul{ border:1px solid black; list-style:none;margin...