加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax动态刷新下拉框

发布时间:2020-12-16 01:41:14 所属栏目:百科 来源:网络整理
导读:动态post,避免直接给页面传输大量数据 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 /** * ajax通过商品刷新供应商 * by_kangyx * @throws IOException */ @RequestMapping (params = "actionMethod=refreshGoodRefSuppliers" ,method = RequestMethod.PO

动态post,避免直接给页面传输大量数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
* ajax通过商品刷新供应商
* by_kangyx
* @throws IOException
*/
@RequestMapping (params = "actionMethod=refreshGoodRefSuppliers" ,method = RequestMethod.POST)
public void refreshGoodRefSuppliers( final Model model,
final HttpServletRequest request, final HttpServletResponse response) throws IOException{
//定义返回字符串
StringBuffer strBuffer = new StringBuffer( "" );
String goodId = request.getParameter( "goodId" );
strBuffer.append( "<option value=''>---请选择---</option>" );
List<GoodRefSuppliers> goodRefSuppliersList = baseSupplierService.getGoodRefSuppliers(Long.valueOf(goodId));
for ( int i= 0 ;i<goodRefSuppliersList.size();i++){
strBuffer.append( "<option value ='" +goodRefSuppliersList.get(i).getSuppliers().getId()+ "'>" +goodRefSuppliersList.get(i).getSuppliers().getName()+ "</option>" );
}
Util.printString(response,strBuffer.toString());
}
1
2
3
4
5
6
7
8
<td>
<select name= "goodRefSuppliers" id= "goodRefSuppliers_${s.index}"
onchange= "setSuppliers(this.value,${orderdetail.id});"
onkeydown= "refreshGoodRefSuppliers(${orderdetail.prdInfo.goodsInfo.id},${s.index});"
onmousedown= "refreshGoodRefSuppliers(${orderdetail.prdInfo.goodsInfo.id},${s.index});" >
<option value= "" >--请选择--</option>
</select>
</td>
1
2
3
4
5
6
7
8
9
10
function refreshGoodRefSuppliers(id,ip){
switchData( 'logisticsOrders.do?actionMethod=refreshGoodRefSuppliers&goodId=' +id, '' ,function(data,flag){
if (flag== 1 ){
if (data!= "" ){
$( "#goodRefSuppliers_" +ip).empty().append(data);
}
}
});
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读