日期:2014-05-16  浏览次数:20309 次

用json格式处理ajax返回多个值

处理端:

echo json_encode(
			     array(
					'a' => $aa, 
					'b' => $bb, 
					'c' => $cc, 
					'd' => $dd, 
					'e' => $ee, 
					'f' => $ff
				      )
			    );
exit;

?接收端(thickbox浮层为底层页面元素赋值):

var id = $("#id").val();
var t = new Date().getTime();
$.ajax({
	   type: "POST",
	   url: "/contracts/schoolinfo",
	   data: "id=" + id + "&time=" + t,
	   dataType:"json",
	   success: function(json){
	     	 top.$("#a").html(json['a']);
	     	 top.$("#b").html(json['b']);
	     	 top.$("#c").html(json['c']);
	     	 top.$("#d").html(json['d']);
	     	 top.$("#e").html(json['e']);
	     	 top.$("#f").html(json['f']);	    	 	
	   }  
});