How to load data using JSON/PHP using jQuery

I have seen a good amount of people wanting to lern how to load data on their website using jquery,JSON and PHP. I have been studying parsing JSON from PHP using AJAX to display it in the client side and jQuery had been a great help to me. Here is a very simple code in parsing JSON using jQuery that i made.

This file makes the request to a php file and displays the returned data into a table.

<a href="#" id="loaduserdata">User Data</a>
<table id="userdata" border="1">
 <th>First Name</th>
 <th>Last Name</th>
 <th>Email Address</th>
 $("#userdata tbody").html("");
 $.each(data.userdata, function(i,user){
 var tblRow =
 $(tblRow).appendTo("#userdata tbody");

This is the file that contains the JSON data.
$json = '{
"userdata": [
 "city":"Laguna Beach"
 "city":"San Angelo"
 "city":"Johnson City"
 "city":"Boulder Junction"
echo $json;

References and Guides:
Download the latest jquery file.
Author: Jhoy Imperial


1 Comment

  1. Zimlu Tang Lee said,

    January 1, 2010 at 3:59 am

    Thanx, mait, now i coprihendo.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: