Ajax 异步请求

window.onload = function() {
    var changGuanId = $("input[name='id']").val();

    if (changGuanId == undefined) {
        return;
    }
  
    $.ajax({
        type : "POST",
        url : ctxfront + "/exhi/flight?changGuanId=" + changGuanId,
        data : {
            "id" : changGuanId
        },
        success : function(data) {
            if (data != "") {// 有数据
                var obj = eval(data.flight);

                for (var i = 0; i < obj.length; i++) {

                    var symbol = '¥';// 钱符号
                    var refid = '96870';// 同程旅旅网提供的ID号
                    var li = "<li><a href='http://www.ly.com/iflight/FlightSearch.aspx?tt=0&orgDate=" + getdateTime() + "&orgCity=" + obj[i].takeoffCity + "&desCity=" + data.city
                            + "&refid=" + refid + "' target='_blank'><span class='locus mr_rt'><em>" + obj[i].takeoffCity + "</em>" + data.city
                            + "<i></i></span><span class='locus tate'><em>" + getBeforeDate(0) + "</em>" + getBeforeDate(30) + "<i></i></span><span class='ht_price'><s>" + symbol
                            + "</s>" + obj[i].salePrice + "</span></a></li>";
                    if (i < 2) {
                        $(flightLeftId).append(li);
                    } else {
                        $(flightrigthId).append(li);
                    }
                }
                $("#flightDiv").attr("style", "display:block;");
            } else {
                $("#flightDiv").attr("style", "display:none;");
            }

        }
    });

}

 

你可能感兴趣的:(Ajax 异步请求)