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()
获取配置文件的选项值,即获取配置文件中某一个选项的值,如果是true值就返回1,如果是false值就返回0,字符串就返回字符串。
例如:
<?p ......
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 ......
原文链接:http://www.phpdo.net/index.php/2010/02/04/1-11/
PHP数组(array)
把值映射到键的类型。
PHP对象(object)
对现实生活中物体的模拟。
PHP空值(null)
表示一个没有值的量。
例如:
<?php
$php = “”;
if(isset($a))
echo “[1] is NULL<br>”; ......
zip.class.php
CODE:
[复制到剪切板]
<?
class
zip
{
var
$datasec
,
$ctrl_dir
= array();
var
$eof_ctrl_dir
=
"x50x4bx05x06x00x00x00x00"
;
var
$old_offset
=
0
; var
$dirs
......
初学JQUERY AJAX使用,不知道怎么实现,找了半天资料都差不多,可是放到我的页面里就是不返回值,后来发现因为没往后台页面传值的原因,加了 data: "name=John&location=Boston"就好用了,这里data:""可为任意值,后台并没有接收。
下面是例子,实现的是获取服务器时间并更新
前台代码:
function getServerTi ......