AJAX参数传递时候如何使用JSON

前端之家收集整理的这篇文章主要介绍了AJAX参数传递时候如何使用JSON前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。



1 两个按钮
<div class="tbl_ctrl">
<!-- <input type="button" value="反选" class="tbl_ctrl_1"/> -->
<autoTag:roleButton authId="103103101" id="transaction" type="button" value="车辆成交" btnClass="btn" />
<autoTag:roleButton authId="103103102" id="fail_auction" type="button" value="车辆流拍" btnClass="btn" />
</div>
======================================================================================
2 为按钮增加点击事件
<script type="text/javascript">

$("#transaction").click(function (){ transactionAuction(); });
</script>
===========================================================================
3 具体的点击事件的触发行为
<script type="text/javascript">
var transactionAuction = function() {
var arrChks=$("input[name='subcheck']:checked");
var sidValue = arrChks[0].value;
var size = arrChks.length;
var arr = new Array();
arr = sidValue.split(",");

if(size>1){


window.alert("只能选择一条记录,不能多选几条记录");
return false;
}


var av_sid = arr[0];//拍品ID
var vehicle_sid = arr[1];//车辆ID
var auctionSid = arr[2];//拍卖会ID
var bidder_sid = arr[3];//竞价人ID
var auction_type = arr[4];//竞拍类型
var auction_status = arr[5];//竞拍状态


if(auction_status !=3){


window.alert("注意!非流拍确认的车辆不能成交");
return false;
}

$.ajax({
type:"post",
dataType:"json",
url:"${ctx}/bidmanage/queryMaxPrice",
data:{avSid:av_sid},//加入有多个数据,则使用,进行分割
success:function(data){
if(data){//这是返回的值

bidPrice = data.price;//如果返回的值有多个,则分别获取,特别适合对象
bidName = data.bidder_name;

$("#bidname").val(bidName);
$("#transc_price").val(bidPrice);


loadFeatureItems();

}else{

window.alert("本次车辆成交失败");
}

}
});





};
</script>
==========================================================
4 AJAX调用的类的方法
@RequestMapping(value = "queryMaxPrice")
@ResponseBody
public BidDisplay queryMaxPrice(String avSid){

BidDisplay bidDisplay = bidService.getMaxPrice(avSid);

return bidDisplay;

}

1 两个按钮
<div class="tbl_ctrl">
<!-- <input type="button" value="反选" class="tbl_ctrl_1"/> -->
<autoTag:roleButton authId="103103101" id="transaction" type="button" value="车辆成交" btnClass="btn" />
<autoTag:roleButton authId="103103102" id="fail_auction" type="button" value="车辆流拍" btnClass="btn" />
</div>
======================================================================================
2 为按钮增加点击事件
<script type="text/javascript">

$("#transaction").click(function (){ transactionAuction(); });
</script>
===========================================================================
3 具体的点击事件的触发行为
<script type="text/javascript">
var transactionAuction = function() {
var arrChks=$("input[name='subcheck']:checked");
var sidValue = arrChks[0].value;
var size = arrChks.length;
var arr = new Array();
arr = sidValue.split(",");

if(size>1){


window.alert("只能选择一条记录,不能多选几条记录");
return false;
}


var av_sid = arr[0];//拍品ID
var vehicle_sid = arr[1];//车辆ID
var auctionSid = arr[2];//拍卖会ID
var bidder_sid = arr[3];//竞价人ID
var auction_type = arr[4];//竞拍类型
var auction_status = arr[5];//竞拍状态


if(auction_status !=3){


window.alert("注意!非流拍确认的车辆不能成交");
return false;
}

$.ajax({
type:"post",//加入有多个数据,则使用,进行分割
success:function(data){
if(data){//这是返回的值

bidPrice = data.price;//如果返回的值有多个,则分别获取,特别适合对象
bidName = data.bidder_name;

$("#bidname").val(bidName);
$("#transc_price").val(bidPrice);


loadFeatureItems();

}else{

window.alert("本次车辆成交失败");
}

}
});





};
</script>
==========================================================
4 AJAX调用的类的方法
@RequestMapping(value = "queryMaxPrice") @ResponseBody public BidDisplay queryMaxPrice(String avSid){ BidDisplay bidDisplay = bidService.getMaxPrice(avSid); return bidDisplay; }

猜你在找的Ajax相关文章