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

JS傳遞對(duì)象數(shù)組為參數(shù)給后端,后端獲取的實(shí)例代碼

 更新時(shí)間:2016年06月28日 09:46:37   投稿:jingxian  
下面小編就為大家?guī)?lái)一篇JS傳遞對(duì)象數(shù)組為參數(shù)給后端,后端獲取的實(shí)例代碼。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

前端JS代碼:

  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");
      }
    });
  });

重點(diǎn)注意:將對(duì)象數(shù)組轉(zhuǎn)為JSON形式的字符串:JSON.stringify

后端獲?。?/strong>

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

以上就是小編為大家?guī)?lái)的JS傳遞對(duì)象數(shù)組為參數(shù)給后端,后端獲取的實(shí)例代碼全部?jī)?nèi)容了,希望大家多多支持腳本之家~

相關(guān)文章

最新評(píng)論