1 回答
TA贡献1811条经验 获得超6个赞
你这个要写在success里面的,可以写个函数把result传过去,比如
$.ajax({
type: "post",
url: "./cgi/xxxxxxxxxx",
dataType: "json",
data: {FromStation: DepartureCity, ArriveStation: ArrivalCity, DepartureDate: DepartDate},
success: function (result) {
console.log(result);
var resultLen = result.length;
for (var i = 0; i < resultLen; i++) {
$(".lv-thead").after(aaa(result));
}
}
});
function aaa(result){
var tickets = '<li class="lv-tbody" data-testdt="202">\
<div>\
<div class="td col1">\
<h3 class="train">'+ result[i].TrainCode+'</h3>\
</div>\
<div class="td col2">\
<p class="start"><i class="ico-start">Start</i><span>Beijing South</span></p>\
<p class="end"><i class="ico-end">End</i><span>Shanghai Hongqiao</span></p>\
</div>\
<div class="td col2">\
<time class="startime">20:00</time>\
<time class="endtime daytime">12:10\
<span title="车次到达日期 2017-12-23" class="i_2day">+2</span>\
</time>\
</div>\
<div class="td col6">\
<time class="duration">40h10m</time>\
</div>\
<div class="td col3" style="width: 214px">\
<p class="ticketed">Business cabins <span class="price"><em class="g-rmb">¥</em>360</span>\
</p>\
<p class="ticketed">First-class seats <span class="price"><em class="g-rmb">¥</em>720</span>\
</p>\
<p class="ticketed">Second-class seats <span class="price"><em class="g-rmb">¥</em>1144</span>\
</p>\
<p class="ticketed">Advanced soft sleeper <span class="price"><em class="g-rmb">¥</em>360</span></p>\
</div>\
<div class="td col4">\
<p class="surplus">100张</p>\
<p class="surplus">100张</p>\
<p class="surplus"><span style="color: #fc773c">仅2张</span></p>\
<p class="surplus"> </p>\
</div>\
</div>\
</li>';
return tickets ;
}
添加回答
举报