代码如下:
jsp:
function get(value)
{
alert(value);
$.getJSON("accountrecharge!getCity.do",{"agentCode":value},function(data){
var second= $("#city")[0];
for(i=0;i<data.length;i++)
{
second.options[i]=new Option(data[i].agentName,data[i].agentCode);
}
});
}
action:
String agentCode=request.getParameter("agentCode");
List<BAgentVo> blist = this.accountRechargeService.searchCityByid(agentCode);
response.setCharacterEncoding("UTF-8");
JSONArray ja=new JSONArray();
try {
PrintWriter out= response.getWriter();
for (Iterator iterator = blist.iterator(); iterator.hasNext();) {
BAgentVo ck = (BAgentVo) iterator.next();
JSONObject jo=new JSONObject();
jo.put("agentCode", ck.getAgentCode());
jo.put("agentName", ck.getAgentName());
ja.add(jo);
}
out.print(ja);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
return null;
jsonaction
jsp:
function get(value)
{
alert(value);
$.getJSON("accountrecharge!getCity.do",{"agentCode":value},function(data){
var second= $("#city")[0];
for(i=0;i<data.length;i++)
{
second.options[i]=new Option(data[i].agentName,data[i].agentCode);
}
});
}
action:
String agentCode=request.getParameter("agentCode");
List<BAgentVo> blist = this.accountRechargeService.searchCityByid(agentCode);
response.setCharacterEncoding("UTF-8");
JSONArray ja=new JSONArray();
try {
PrintWriter out= response.getWriter();
for (Iterator iterator = blist.iterator(); iterator.hasNext();) {
BAgentVo ck = (BAgentVo) iterator.next();
JSONObject jo=new JSONObject();
jo.put("agentCode", ck.getAgentCode());
jo.put("agentName", ck.getAgentName());
ja.add(jo);
}
out.print(ja);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
return null;
jsonaction
解决方案 »
- 有关EXT的tree叶子节点的click事件,弹出一个tabpanel
- EXTJS弹出框的问题?
- ExtJS获取后台数据问题,麻烦帮看看!
- 100元人民币求解,简单的JS+asp代码整合
- upload_5xsoft.inc 这个有问题,被卡巴,AVG自动删!我真急!帮我写的!
- 判断一个字符串的首字母??
- javascript 操作xml问题
- 紧急求救!关于在Web上打印出两图互相穿插的图片!!
- 360下div如何遮挡包含flash的div
- 移动端 购物车缩小-变大-还原的效果怎么做?
- My97DatePicker里面的$dp.hide怎么使用
- 求助::静态网页里插入的rmvb格式的文件,上传服务器就不能播放了。
错误就很明显了。