欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery向后臺(tái)提交數(shù)組的代碼分析

 更新時(shí)間:2020年02月20日 10:48:37   作者:huiy_小溪  
在本篇文章里小編給大家整理的是一篇關(guān)于jquery向后臺(tái)提交數(shù)組的相關(guān)知識(shí)點(diǎn)內(nèi)容,需要的朋友們可以參考學(xué)習(xí)下。

jquery:向后臺(tái)提交數(shù)組

var resArray = new Array(1,2,3);$.post(prefix + '/save/res/', {
    'roleID' : $('#roleID').val(),
    'resArray' : resArray,
  }, function(result) {
    top.closeLayer();
    if (result.state == 'succ') {
      top.refreshRight();
      top.okLayer('維護(hù)角色', '保存數(shù)據(jù)成功');
    } else {
      top.errorLayer('維護(hù)角色', '保存數(shù)據(jù)失敗');
    }
  }, 'json');

后端接收,以springboot為例:

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

resArray[] 必須這樣寫!

實(shí)例補(bǔ)充

jQuery.ajax向后臺(tái)傳遞數(shù)組問(wèn)題

//創(chuàng)建一個(gè)測(cè)試數(shù)組
var boxIds = new Array();
boxIds.push(12182);
boxIds.push(12183);
boxIds.push(12184);
//向后臺(tái)交互
$.ajax({
  url: "/xxx",
  type: "GET",
  data: {
    "boxIds": boxIds,
    "boxType": 0,
    "time": new Date().getTime()
  },
  success: function(data) {
    //do sth...
  }
});

后臺(tái)controller代碼(SpringMVC)

@ResponseBody
@RequestMapping(value = "/box/changeLock")
public String changeLock(final Long[] boxIds, final int boxType) {
  return locker_ChangeLockService.changeLock(boxIds, boxType);
}

以上就是腳本之家小編結(jié)合多篇后整理的相關(guān)內(nèi)容,希望能夠幫助到大家。

相關(guān)文章

最新評(píng)論