O'Reilly logo

PHP jQuery Cookbook by Vijay Joshi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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...

  1. Create a file named index.html in the newly created Recipe4 folder.
  2. 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required