ajax pass array servelt background receive array

tags: json  ajax  java

ajax

  $.ajax({
                                                                            url : 'Admin_User_management?3',
                                                                            type: 'post',
                                                                            data : {id:ids},
                                                                            traditional: true,
                                                                            success : function(data) {
                                                                                //console.info(ids.join(','));
                                                                                //console.log(data)
                                                                                //datagrid.datagrid('load',data);
                                                                                //datagrid.datagrid('reload');// Return the currently selected row
                                                                            }
                                                                        })

servlet code

String[] ids = request.getParameterValues("id");//Get the passed array
        
                 JSONArray jsonData = new JSONArray();//json data
        db_admin.Admin_Del_user(ids);
        PrintWriter out = response.getWriter(); Map<String, Object> map = new
        HashMap<String, Object>(); map.put("msg", "success");
                 jsonData.fluentAdd(map); out.println(jsonData);//return data out.flush();
        out.close();

 //You can also get it like this

 //Shopping cart click to pay
    @RequestMapping("/Cart_Pay.action")
    public String Cart_Pay(HttpServletRequest request, HttpServletResponse respone) {
                 String json_data2 = request.getParameter("json_data");//Get the passed array
        List<HashMap> map = JSONArray.parseArray(json_data2, HashMap.class);
        for(HashMap<String,Object> map1:map) {
            String id = map1.get("id").toString();
            String total = map1.get("total").toString();
            System.out.println(id);
            System.out.println(total);
        }
                 //JSONArray jsonData = new JSONArray();//json data
        
        return "/Cart.jsp";
    }

Intelligent Recommendation

Ajax asynchronous request transfers the array to the background, the background cannot receive

In the development process, because the business needs to do batch tasks, the id is often encapsulated into an array and passed to the background for batch processing. The ordinary ajax parameter tran...

How can't ajax submit background receive json array object

Solve ajax unable to receive array objects Problem Description: The front end sends the ajax array object; such as:{“tids”:["1","2","3"]}, The current station...

**About AJAX appears to receive no background pass worthy**

About AJAX appears to receive no background pass worth In a recent project to determine whether to add successful data, use ajax to submit the value from the form, found that the background return val...

Springmvc pass and receive array parameters

                       How to pass an array in java url, how does the springMVC framework contr...

Ajax pass array

Passing data in ajax can be used   Background reception can be used:   Note: The key is the $.ajax({traditional: true,}) setting, not the next String[] checkedIds can't receive the value. &n...

More Recommendation

Ajax pass array and object

Ajax pass array: Ajax pass object:  ...

ajax pass an array parameter

Examples   ...

ajax pass an array to springmvc

Backstage $.ajax({ url: “/bill/distribute”, type: “post”, data: {“ids”: 1,2,3,4,5,}, dataType: “json”, success: function (data) { Global.success(success...

Using ajax to pass an array

If you want to use ajax to pass the array to the background,traditional must be set to true。...

ajax pass array parameters

similar parameters...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top