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

ajax 后台获取String传到前台

1,页面调用ajax

new Ajax.Request('${ctx}/customer/card/creat-card-verifycode', {
			method: 'get',
			parameters: { contactId: cardHoldId },
			onComplete: function(dispatcher) {
			//TODO  分析ajax返回值
			}
		});

?

2,后台实现ajax

private List<String> virifyCodeList = new ArrayList<String>();

public String ajax(){
     virifyCodeList.add(String);
     return "j:virifyCodeList"; 
}

?

3,前台获取值,分析

onComplete: function(dispatcher) {
	var virifyCodeList = dispatcher.responseText.evalJSON();
	$("verifyCode").value=virifyCodeList[0];
}

?

?