I am validating a login form using ajax call. It is working great when you enter the wrong information. But if you enter the right credentials nothing happens. I am confused what to do? sample code:
我正在使用ajax調用驗證登錄表單。當你輸入錯誤的信息時,它工作得很好。但如果您輸入正確的憑證,則不會發生任何事情。我不知道該怎么辦?示例代碼:
$.ajax({
type: 'POST',
url: URL +'/foo/',
data: {'uname': name, 'password':pass},
success: function(data) {
if (data["success"] === "false") {
//show some message
$("#password").val("");
}
else {
// here i want to redirect to some url say, /bar/
I am confused how to do it.
},
dataType: "json",
});
return false
3 个解决方案
#1
3
you can use javascript.
您可以使用javascript。
location.href="new url";
it will take you to the new url
它將帶您到新的url
var querystringParam="sample";
var tempUrl="http://www.test.com?" + "variablettopass=" + querystringParam
location.href=tempUrl;
if you have more than one append to query string...
如果查詢字符串有多個附加項……
if you want your server name from browser window use this code
如果您希望您的服務器名稱從瀏覽器窗口使用此代碼。
window.location.hostname
but if you do location.href // it will take care...i just gave you for info
但是如果你選擇位置。href //它會小心的…我只是給你一些信息
#2
0
$(location).attr("href","url here")
#3
0
Try this:
試試這個:
window.location = url;