前台ajax不能循环执行,需要向后台传值,后台循环 id in (1,2,3);

 ajax({
                            url : "appcanAjax/appProject_updateFlag",
                            data : {
                                ids : ids.toString(),
                            },
                            dataType : "json",
                            successx : function(data) {
                            },
                            error : function(xhr, type) {
                                $toast("网络连接超时", 3500);
                            }
                        });

                },
                error : function(xhr, type) {
                    $toast("网络连接超时", 3500);
                }
            });
View Code

  id in (1,2,3);

id会自动循环

 

 

/**
* 根据towerId修改flag
*/
public String updateFlag() {


System.out.println(ids);

towerService.updateByIds(ids, 1);


// String jsonResult = JSONObject.fromObject(tower).toString();
//
// try {
// response.getWriter().write(jsonResult);
// } catch (Exception e) {
// e.printStackTrace();
// }

return null;
}

 

 

 

@Override
public void updateByIds(String ids,int flag) {
String hql="update Tower set flag="+flag+" where id in ("+ids+")";
towerDaoUtil.updateByhql(hql);
}

posted @ 2016-11-28 10:33  百事没事  阅读(461)  评论(0编辑  收藏  举报