繁体   English   中英

Window.location无法正常工作

[英]Window.location doesn't work properly

我想在我的ajax调用返回成功后重定向。 我试过window.locationwindow.location.hrefself.location但是页面没有重定向到目标页面。 这是我所有的ajax邮政编码:

$(document).on('click', '.btn_Yeni', function (event) {
var date= $("#deSeansTarihi").val();
var _iHastaId= $("#hdnHastaId").val();

date= date.toString().substring(3, 5) + "." + date.toString().substring(0, 2) + "." + date.toString().substring(6, 10);

$.ajax({
    type: "POST",
    url: "KlinikHastalari.aspx/SetNewData",
    data: JSON.stringify({ _dtTarih: date, _id: _iHastaId}),
    dataType: "json",
    async: true,
    contentType: "application/json; charset=utf-8",
    success: function (msg) {
        window.location("http://localhost:59508/trunk/abs.aspx?hid=" + _iHastaId);
    }
});

});

SetNewData函数返回成功。 我该怎么做才能重定向目标页面?

window.location工作正常。 问题是你把它当成一种功能。 它不是一个函数,你只需分配给它:

window.location = "http://localhost:59508/trunk/abs.aspx?hid=" + _iHastaId;

在我看来,你在代码中使用jQuery Mobile。 因此,您还可以使用$.mobile.changePage重定向到新页面。 请查看此处的参考: http//api.jquerymobile.com/jQuery.mobile.changePage/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM