javascript基础(柯里化)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>jskeli</title>
	<script type="text/javascript">
	///update return a function ,that could update some text;
	   function update(data){
	      return function(text){
	        console.log(data+":"+text);
	      }
	   }
	 ////ajax request. success when call the  callback 
		function refresh(url,callback){
		   var params={
                  type:"",
                  data:""
		
		     };
		   $.ajax({
				type:"post",
				url:url,
				cache:false,
				async:true,
				dataType:"json",
				data:params,
		   success:function(data,status){
		       callback(data);
		   }		  
		   error:function(err){
		     
		       alert("error");
		   }			  
		   }) 
		  }
	 refresh("action.do?target=news",update("news"));
	</script>
</head>
<body>
</body>
</html>

你可能感兴趣的:(javascript基础(柯里化))