Fetching data from PHP using jQuery
This recipe will teach you the usage of jQuery's get
method to retrieve data from a PHP script. We will see a simple example where data will be fetched from the server using the get
method based on user selection from a form.
Getting ready
Create a directory named chapter2
in your web root. Put the jQuery library file in this directory. Now create another folder inside and name it as Recipe1
. As a recipe can have more than one file, it is better to keep them separate.
How to do it...
Create a file
index.html
in theRecipe1
folder. Write the HTML code in it that will create a combo box with some options.<html> <head> <title>jQuery.get()</title> <style type="text/css"> ul{border:1px solid black; list-style:none;margin:0pt;padding:0pt;float:left;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;width:300px;} li{padding:10px 5px;border-bottom:1px solid black;} </style> </head>...