html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
</head>
<body>
<center>
<input type="text" name="net" />
<input type="button" id="search" value="查询" />
<div id="div1"></div>
</center>
</body>
</html>
<script src="jq.js"></script>
<script>
$(function(){
$("#search").click(function(){
var net=$("input[name='net']").val();
$.get("b.php?net="+net,function(data){
$("#div1").html(data);
})
})
})
</script>
php和memcache 处理html请求
<?php
header("connect-type:text/html;charset=utf-8");
if($_GET){
$net =$_GET['net'];
$mem = new Memcache();
$mem->connect('127.0.0.1',11211);
$re = $mem->get("net_$net");
//$mem->flush();die;
if(!$re){
$url ="http://api.k780.com:88/?app=life.areacode&areacode=$net&appkey=19795&sign=a5b8accdcd606114305060b452cd8de5&format=xml";
$obj =simplexml_load_file($url);
$json = json_encode($obj);
$arr =json_decode($json,true);
$short=$arr['result']['lists']['item_0']['areanm'];
print_r($short);
$mem->set("net_$net",$short);
}else{
$short=$re;
echo "这是缓存";
}
}else{
echo "非法操作";
}
?>