JSON字符串 :{"ticketname":"太原清华软件园门票","sanprice":14,"netprice":0,"tuanprice":10,"marketprice":15}
转换方法 $.parseJSON(data)
JSP页面:
$(document).ready(function() {
//为inputForm注册validate函数
$("#inputForm").validate();
$('#ticket').change(function(){
var v=$(this).children('option:selected').val();
alert(v);
$.ajax({
type : 'POST',
url : "${ctx}/ticket/getTicket",
data : {
id : v
},
success : function(data) {
var ticket = $.parseJSON(data)
$('#marketprice').val(ticket.marketprice);
$('#sanprice').val(ticket.sanprice);
$('#tuanprice').val(ticket.tuanprice);
$('#netprice').val(ticket.netprice);
alert(5555)
},
error:function(){
alert(2);
}
});
});
});