Parsing JSON Data from PHP Using jQuery (ajax)
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.
tablejsondata.php
This file makes the request to a php file and displays the returned data into a table.
<html>
<head>
<title>Parsing JSON from PHP Using jQuery</title>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript">
</script>
</head>
<body>
<a href="#" id="loaduserdata">User Data</a>
<table id="userdata" border="1">
<thead>
<th>First Name</th>
<th>Last Name</th>
<th>Email Address</th>
<th>City</th>
</thead>
<tbody></tbody>
</table>
<script>
$(document).ready(function(){
});
$("#loaduserdata").click(function(){
$("#userdata tbody").html("");
$.getJSON(
"jsondata
.php
",
function(data){
$.each(data.userdata, function(i,user){
var tblRow =
"<tr>"
+"<td>"+user.first+"</td>"
+"<td>"+user.last+"</td>"
+"<td>"+user.email+"</td>"
+"<td>"+user.city+"</td>"
+"</tr>"
$(tblRow).appendTo("#userdata tbody");
});
}
);
});
</script>
</body>
</html>
jsondata.php
This is the file that contains the JSON data.
<?php
$json = '{
"userdata": [
{
"first":"Ciaran",
"last":"Huber",
"email":"elementum.purus@utdolordapibus.edu",
"city":"Mayagüez"
},
{
"fi
Ïà¹ØÎĵµ£º
»ùÓÚPHPÓïÑÔµÄÂÛ̳¿ÉÒÔ˵ÊÇĿǰ×ȫ¶øÇÒÖ´ÐдúÂëЧÂÊ×î¸ßµÄÂÛ̳ÁË£¬ºÍASPÏà±ÈËû¿ÉÒÔʵÏÖºÍMYSQL¸üºÃ½áºÏµÄÌØµã£¬½áºÏPHPMYADMIN¿ÉÒÔ¸üºÃµÄ¹ÜÀíºÍά»¤Êý¾Ý¿âÐÅÏ¢¡£Ò»°ãÇé¿öÏÂʹÓÃapacheºÍPHP´îÅä±È½Ï˳ÊÖ£¬²»¹ýºÜ¶àʱºòÓÉÓÚÌØ¶¨ÒòËØºÍÌõ¼þµÄ¾ÖÏÞ£¬ÎÒÃÇÒªÇóÔÚIIS»ù´¡ÉϽ¨Á¢PHPÓ¦Óû·¾³¡£½ñÌì±ÊÕß¾ÍΪ¸÷λ½éÉÜÈçºÎÔÚIISºÍWin ......
It is possible to define constant values on a per-class basis remaining the same and unchangeable.
Constants differ from normal variables in that you don't use the $ symbol to declare or use them. Like static members, constant values cannot be accessed from an instance of the object (using $obje ......
³õѧJQUERY AJAXʹÓ㬲»ÖªµÀÔõôʵÏÖ£¬ÕÒÁ˰ëÌì×ÊÁ϶¼²î²»¶à£¬¿ÉÊǷŵ½ÎÒµÄÒ³ÃæÀï¾ÍÊDz»·µ»ØÖµ£¬ºóÀ´·¢ÏÖÒòΪûÍùºóÌ¨Ò³Ãæ´«ÖµµÄÔÒò£¬¼ÓÁË data: "name=John&location=Boston"¾ÍºÃÓÃÁË£¬ÕâÀïdata:""¿ÉΪÈÎÒâÖµ£¬ºǫ́²¢Ã»ÓнÓÊÕ¡£
ÏÂÃæÊÇÀý×Ó£¬ÊµÏÖµÄÊÇ»ñÈ¡·þÎñÆ÷ʱ¼ä²¢¸üÐÂ
ǰ̨´úÂ룺
function getServerTi ......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0044)http://www.qqip.cn -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>new document</TITLE>
<META ht ......
À´Ô´ÓÚ£ºhttp://news.csdn.net/a/20100205/216909.html
¾Ý¡¶Å¦Ô¼Ê±±¨¡·ÍøÕ¾±¨µÀ
£¬¶ÁÐ´Íø¼ÇÕßÓëPHPµÄ´´ÔìÕßRasmus LerdorfÁªÏµ£¬Ñ¯ÎÊËû¶ÔFacebook¸Õ¸Õ¿ªÔ´µÄPHPÓÅ»¯ÏîÄ¿HipHopÓкο´·¨¡£LerdorfÔÚÓʼþÖÐ˵£¬ÕâÊÇÒ»¸öºÜ¿áµÄÏîÄ¿£¬¿Ï¶¨»á³ÉÎªÄ³Ð©ÍøÕ¾ºÜºÃµÄÑ¡Ôñ¡£
µ«ÊÇ£¬Ëû½ÓÏÂÀ´Ëµ£¬¶ÔÓÚÐí¶àWebÓ¦ÓÃÀ´Ëµ£¬Ö´ÐÐËٶȲ¢²»ÊÇÖ ......