js前端ajax提交list集合參數至後端__js

來源:互聯網
上載者:User

JS部分
var orderNosList = new Array();var rows = $("#dg_linkOrder").datagrid("getChecked");if(rows.length < 1){$('#error').dialog('open').dialog('center').dialog('setTitle', '錯誤提示');$('#error').text("請選擇一條資料");}else  {for (var i = 0; i < rows.length; i++) {orderNosList[i] = rows[i].orderNo;}var params = {reserveOrderNoList:orderNosList };$.ajax({url : api.LINK_ORDER_RESERVE_RETRY,data : JSON.stringify(params),type : 'POST',contentType: "application/json",dataType : 'json',success : function(res) {var str = '';$(res.reserveFlowList).each(function(i, obj){var responseCode = obj.responseCode;var orderNo = obj.reserveFlow.orderNo;if (responseCode == 0) {str += "訂單號為"+ orderNo +"成功<br/>";} else {str += "訂單號為"+ orderNo + obj.responseMsg +"<br/>"}});$('#error2').dialog('open').dialog('center').dialog('setTitle', '提示');$('#error2').html(str);// 重新整理列表linkOrder.unfresh_LinkOrder();}});}

var demo = new Object();demo.name="1";demo.id="2";var demo2 = new Object();demo2.name="1";demo2.id="2";var conditons = [];conditons.push(demo);conditons.push(demo2);$(function(){  $.ajax({    type:'post',    url:'/http/pss/demo', contentType: "application/json",    data:{name:"123",conditions:JSON.stringify(conditons)},    dataType : 'json',     success:function(data){      console.log(data);    },    error: function (XMLHttpRequest, textStatus, errorThrown){      alert("error");    }  });});




JAVA後端
@RequestMapping("/http/pss/reserveOrderRetry")@ResponseBodypublic Object reserveOrderRetry(@RequestParam("reserveOrderNoList")List<String> reserveOrderNoList) {return service.reserveOrderRetry(reserveOrderNoList);}

@RequestMapping("/http/pss/reserveOrderRetry")@ResponseBodypublic Object reserveOrderRetry(@RequestParam("conditions")List<Demo> conditions,        @RequestParam("name")String name) {}




相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.