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ÖÐÌṩËĸöº¯ÊýʵÏÖ¶Ôphp.iniµÄ²Ù×÷£ºini_get¡¢ini_set¡¢ini_get_all¡¢ini_restore
ÆäÖÐ×î³£ÓõÄÊÇini_setºÍini_get¡£
ÏÂÃæ¾ßÌåÀ´ËµËµÕâÁ½¸öº¯ÊýµÄ×÷Óãº
ini_get()
»ñÈ¡ÅäÖÃÎļþµÄÑ¡ÏîÖµ£¬¼´»ñÈ¡ÅäÖÃÎļþÖÐijһ¸öÑ¡ÏîµÄÖµ£¬Èç¹ûÊÇtrueÖµ¾Í·µ»Ø1£¬Èç¹ûÊÇfalseÖµ¾Í·µ»Ø0£¬×Ö·û´®¾Í·µ»Ø×Ö·û´®¡£
ÀýÈ磺
<?p ......
SymfonyÊÇÒ»¸öÈ«¹¦ÄܵÄPHP¿ª·¢¿ò¼Ü£¬¿ª·¢ÓïÑÔΪPHP5.ËüÏò³ÌÐòÔ±ÌṩÁËÁ¼ºÃµÄ¼Ü¹¹£¬³£ÓõŦÄÜ×é¼þ¼°¹¤¾ß£¬¿ÉÓÃÓÚ¿ìËÙ´´½¨¸´ÔÓµÄWEB³ÌÐò¡£Ñ¡ÔñSymfony¿ÉÒÔÈÃÄã¸ü¿ìµØ·¢²¼ÄãµÄ²úÆ·£¬²¢ÇÒºÜÈÝÒ×ÔËÓªºÍÀ©Õ¹¡£SymfonyµÄÍŶӺÜÓоÑ飬²»Öظ´·¢Ã÷ÂÖ×Ó£ºËüʹÓÃÁ˺ܶàWEB¿ª·¢Öеē×î¼Ñʵ¼ù”²¢¼¯³ÉÁËһЩÓÅÐãµÄµÚÈý·½Àà¿ ......
zip.class.php
CODE:
[¸´ÖƵ½¼ôÇаå]
<?
class
zip
{
var
$datasec
,
$ctrl_dir
= array();
var
$eof_ctrl_dir
=
"x50x4bx05x06x00x00x00x00"
;
var
$old_offset
=
0
; var
$dirs
......
jQuery Ajax È«½âÎö
±¾ÎĶÌÖ·£ºhttp://s8.hk/0itq
<!--
.ajax div{
border: solid 1px red;
}
-->
// <![CDATA[
$(function(){
$("#btnajax").click(function(){
$.ajax({
type: "get",
url: "/rss",
beforeSend: function(XMLHttpRequ ......
DWR(Direct Web Remoting)ÊÇÒ»¸öWEBÔ¶³Ìµ÷Óÿò¼Ü.ÀûÓÃÕâ¸ö¿ò¼Ü¿ÉÒÔÈÃAJAX¿ª·¢±äµÃºÜ¼òµ¥.ÀûÓÃDWR¿ÉÒÔÔÚ¿Í»§¶ËÀûÓÃJavaScriptÖ±½Óµ÷Ó÷þÎñ¶ËµÄJava·½·¨²¢·µ»ØÖµ¸øJavaScript¾ÍºÃÏñÖ±½Ó±¾µØ¿Í»§¶Ëµ÷ÓÃÒ»Ñù(DWR¸ù¾ÝJavaÀàÀ´¶¯Ì¬Éú³ÉJavaScrip´úÂë).ËüµÄ×îа汾DWR0.6Ìí¼ÓÐí¶àÌØÐÔÈç:Ö§³ÖDom TreesµÄ×Ô¶¯ÅäÖÃ,Ö§³ÖSpring(JavaS ......