ajax动态刷新下拉框

前端之家收集整理的这篇文章主要介绍了ajax动态刷新下拉框前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

动态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)
@H_404_91@public @H_404_91@void refreshGoodRefSuppliers( @H_404_91@final Model model,
@H_404_91@final HttpServletRequest request, @H_404_91@final HttpServletResponse response) @H_404_91@throws IOException{
//定义返回字符串
StringBuffer strBuffer = @H_404_91@new StringBuffer( "" );
String goodId = request.getParameter( "goodId" );
strBuffer.append( "<option value=''>---请选择---</option>" );
List<GoodRefSuppliers> goodRefSuppliersList = baseSupplierService.getGoodRefSuppliers(Long.valueOf(goodId));
@H_404_91@for ( @H_404_91@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){
@H_404_91@if (flag== 1 ){
@H_404_91@if (data!= "" ){
$( "#goodRefSuppliers_" +ip).empty().append(data);
}
}
});
}
原文链接:https://www.f2er.com/ajax/162306.html

猜你在找的Ajax相关文章