Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to submit an array to the background by jquery

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge of this article "jquery how to submit an array to the background", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "jquery how to submit an array to the background" article.

Jquery: submit an array to the background

Var resArray = new Array; $.post (prefix +'/ save/res/', {'roleID': $(' # roleID'). Val (), 'resArray': resArray,}, function (result) {top.closeLayer (); if (result.state = =' succ') {top.refreshRight (); top.okLayer ('maintenance role', 'data saved successfully') } else {top.errorLayer ('maintenance role', 'failed to save data');}}, 'json')

Backend receiver, take springboot as an example:

@ RequestParam (name = "resArray []", required = false) String [] resArray

ResArray [] must be written like this!

Examples add:

JQuery.ajax passes the array problem to the background

/ / create a test array var boxIds = new Array (); boxIds.push (12182); boxIds.push (12183); boxIds.push (12184); / / interact with the background $.ajax ({url: "/ xxx", type: "GET", data: {"boxIds": boxIds, "boxType": 0, "time": new Date (). GetTime ()}, success: function (data) {/ / do sth...) })

Background controller code (SpringMVC)

@ ResponseBody@RequestMapping (value = "/ box/changeLock") public String changeLock (final Long [] boxIds, final int boxType) {return locker_ChangeLockService.changeLock (boxIds, boxType);} the above is about "how to submit arrays to the backend by jquery". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about it, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report