Accessing data from a JSON in jQuery
So, now we know how to generate JSON using PHP. We can put this knowledge of ours to some real use. We will write an example that will request some JSON data from PHP (using jQuery of course) and then we will display it in the web page.
Getting ready
Create a folder for this recipe inside the Chapter4
directory and name it Recipe4
.
How to do it...
Create a file named
index.html
in the newly createdRecipe4
folder.Write some HTML code in this file that will create and empty select box and an empty unordered list. Also define some CSS styles for these elements in the
<head>
section.<?php <html> <head> <title>Accessing data from a JSON</title> <style type="text/css"> body,select,ul{ font-family:"trebuchet MS",verdana } ul{ list-style::none;margin:0pt;padding:0pt;} </style> </head> <body> <h3>Select a date to view Travel Details</h3> <p> <select id="travelDates...