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

jQuery AJAX实例(包含JSON)
	function checkUserNumPerAcco() {
		var warningHtml = '<font color="red">(用户数少于2人!)</font>';
		
		var status = true;
		$("input:hidden[name='accoIdMark']").each(function() {
			var accoId = this.value;
			$.ajax({
				   type: "POST",
				   url: "<%=basePath%>accounting/baseInfoAction.do?method=checkUserNumPerAcco",
				   data: "accoId=" + accoId,
				   success: function(res){
				     	var json;
				     	
				     	//JSON对象组装
				     	eval("json = " + res + ";");
				     	
				     	if(!json.success) {
				     		status = false;
				     		return;
				     	}
				     	
				     	//已分配用户数<2的,在帐套名称后添加提示信息
				     	if(json.userNum < 2) {
							$("#user_num_warn_" + accoId).html(warningHtml);
						} else {
							$("#user_num_warn_" + accoId).html("&nbsp;");
						}
				   },
				   failure: function(){
				   		status = false;
				   }
			}); 
		});
		
		if(!status) {
		      alert("获取帐套已分配用户数失败,请检查网络连接!");
		}
	}