window.location
works just fine. The problem is you're treating it like a function. It isn't a function, you just assign to it:
window.location = "http://localhost:59508/trunk/abs.aspx?hid=" + _iHastaId;
質問
I want to redirect after my ajax call return succeed. I tried window.location
, window.location.href
, self.location
but page doesn't redirect to target page. Here is my all ajax post codes:
$(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 function returns succeed. What should I do to redirect target page?
解決
window.location
works just fine. The problem is you're treating it like a function. It isn't a function, you just assign to it:
window.location = "http://localhost:59508/trunk/abs.aspx?hid=" + _iHastaId;
他のヒント
It seems to me like you are using jQuery Mobile in your code.
Therefore you could also use $.mobile.changePage
to redirect to a new page.
Check the reference here: http://api.jquerymobile.com/jQuery.mobile.changePage/