mrzzzblog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var conditons = [];
var test1 = new Object();
test1.name= "1" ;
test1.id= "2" ;
var test2 = new Object();
test2.name= "1" ;
test2.id= "2" ;
conditons.push(test1);
conditons.push(test2);
$( function (){
  $.ajax({
    async: "false" ,
    type: \'post\' ,
    url: \'链接\' ,
    data:{name: "123" ,conditions:JSON.stringify(conditons)},
    dataType : \'json\' ,
    success: function (data){
      console.log(data);
    },
    error: function (XMLHttpRequest, textStatus, errorThrown){
      alert( "error" );
    }
  });
});

重点注意:将对象数组转为JSON形式的字符串:JSON.stringify

后端获取:

?
1
2
String conditions = request.getParameter( "conditions" );
JSONArray conditionList = JSONArray.fromObject(conditions);

以上就是小编为大家带来的JS传递对象数组为参数给后端,后端获取的实例代码全部内容了,希望大家多多支持脚本之家~

分类:

技术点:

相关文章:

  • 2022-01-06
  • 2021-07-03
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-30
  • 2022-12-23
  • 2021-11-08
  • 2021-11-20
  • 2021-10-30
相关资源
相似解决方案