成功通过我的网络服务登录后,我无法重定向到另一个。我从Web服务得到正确的响应但是页面没有重定向。
<script type="text/javascript">
function registerUser() {
try {
var username = document.getElementById("UserName");
var pwd = document.getElementById("Password");
$.ajax({
datatype: "json",
type: "POST",
url: "http://localhost:51290/CMSWebService.asmx/LoginUser",
data: "{'username':'" + username.value + "','pwd':'" + pwd.value + "'}",
async:false,
contentType: "application/json; charset=utf-8",
success: function (data) {
alert("hello");
window.location.replace("default.aspx");// to redirect error occurs here
},
error: function (data) {
debugger;
if (data.d) {
}
}
});
}
catch (e) {
debugger;
alert(e);
}
}
</script>
答案 0 :(得分:0)
为什么不试试window.location.replace(“你网页的完整网址”)。
答案 1 :(得分:0)
<script type="text/javascript">
function registerUser() {
try {
var username = document.getElementById("UserName");
var pwd = document.getElementById("Password");
$.ajax({
datatype: "json",
type: "POST",
url: "http://localhost:51290/CMSWebService.asmx/LoginUser",
data: "{'username':'" + username.value + "','pwd':'" + pwd.value + "'}",
async:false,
contentType: "application/json; charset=utf-8",
success: function (data) {
window.location = "./default.aspx";
alert("hello");
},
error: function (data) {
debugger;
if (data.d) {
}
}
});
}
catch (e) {
debugger;
alert(e);
}
}
</script>
试试这个