闭包
结合ajax段代码
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery.min.js" language="javascript" type="text/javascript">
</script>
<script src="wkl_ajax.js" language="javascript" type="text/javascript">
</script>
<script type="text/javascript">
function load()
{
_ape_json_.search("http://localhost/me.php", function(meed){
alert(meed.just+"1...");
});
shit();
}
function shit()
{
var test = "xiaoxiao"
_ape_json_.search("http://localhost/me.php", function(meed){
alert(meed.just+"12..."+test);
});
}
function f1(){
var n=999;
nAdd=function(){n+=1}
function f2(){
alert(n);
}
return f2;
}
var result=f1();
result(); // 999
nAdd();
result(); // 1000
</script>
</head>
<body onload="load()">
<div class="me">test</div>
</body>
</html>
完