window.location返回不同的值

时间:2018-03-24 15:21:37

标签: javascript jquery asp.net window.location contentplaceholder

我遇到了问题:https://ibb.co/ccx5c7

var _yolcuSayisiYetiskin = $("#slcYolcuYetiskin").text();
var _yolcuSayisiCocuk = $("#slcYolcuCocuk").text();
var _yolcuSayisiBebek = $("#slcYolcuBebek").text();
var _gidisOriginCode = $('#inpNeredenAirportCode').val();
var _gidisDestinationCode = $('#inpNereyeAirportCode').val();
var dateGidisTarihi = $("#departure_date").val();

if (dateGidisTarihi.match(/[a-zA-Z\s]/g)) {
    return false;
}
else {
    if (dateGidisTarihi.length > 0) {
        $("#departure_date").css("color", "#000");
    }
    else {
        $("#departure_date").css("color", "#d14300");
        $("#departure_date").val("Bu alan boş geçilemez!");
        return false;
    }
}

var _gidisTarih = dateGidisTarihi; // After
var _donusTarih = $("#return_date").val();
var _ucusTipi = $("#orUcusTipiTekYon").prop('checked') ? "OW" : "RT";
var requestPath = "/Ucus/Seferler.aspx?gdOriginCode=" + _gidisOriginCode
    + "&gdDestinationCode=" + _gidisDestinationCode
    + "&gTarih=" + _gidisTarih
    + "&dTarih=" + _donusTarih
    + "&ysYetiskin=" + _yolcuSayisiYetiskin
    + "&ysCocuk=" + _yolcuSayisiCocuk
    + "&ysBebek=" + _yolcuSayisiBebek;

window.location = requestPath;

requestPath/Ucus/Seferler.aspx?gdOriginCode=ADATR&gdDestinationCode=IST&gTarih=30.03.2018&dTarih=&ysYetiskin=1&ysCocuk=0&ysBebek=0

window.location会返回http://localhost:1374/Ucus/Seferler.aspx?ctl00%24ContentPlaceHolder1%24inpNereden=Adana+-+T%C3%BCrkiye%28Sakirpasa-ADA%29&ctl00%24ContentPlaceHolder1%24inpNeredenAirportCode=ADATR&ctl00%24ContentPlaceHolder1%24inpNeredenCountryCode=TR&ctl00%24ContentPlaceHolder1%24inpNeredenCountryName=T%C3%BCrkiye&ctl00%24ContentPlaceHolder1%24inpNeredenCityName=Adana&ctl00%24ContentPlaceHolder1%24inpNereye=%C4%B0stanbul+-+T%C3%BCrkiye%28Ataturk-IST%29&ctl00%24ContentPlaceHolder1%24inpNereyeAirportCode=IST&ctl00%24ContentPlaceHolder1%24inpNereyeCountryCode=TR&ctl00%24ContentPlaceHolder1%24inpNereyeCityName=Istanbul&ctl00%24ContentPlaceHolder1%24departure_date=30.03.2018&ctl00%24ContentPlaceHolder1%24return_date=

1 个答案:

答案 0 :(得分:0)

据我了解,您想要重定向到requestPath。如果您想这样做,则必须使用:location.href = requestPath