1. 程式人生 > >js表單提交到後臺物件接收

js表單提交到後臺物件接收

$.extend({
StandardPost:function(url,args){
var form = $("<form method='post' target='_blank'></form>"),
input;
form.attr({"action":url});
$.each(args,function(key,value){
input = $("<input type='hidden'>");
input.attr({"name":key});
input.val(value);
form.append(input);
});
form.appendTo('body').submit().remove();
}
});

 

下單點選按鈕觸發事件:
$("#btn_test").click(function () {
var data = {
maxQuotationNo:"",
maxPrice:,
salePrice:10000.00,
dealerId:,
buyerId:
};
$.StandardPost('http://***/***/**/toDisposePage', data);
});

後臺取值:post 物件接收
@RequestMapping(value = "/printAgreement", method = RequestMethod.POST)
public ModelAndView printAgreement(ModelAndView modelAndView, ReceiptInstallmentVO vo ) {