如何在ajax中重定向页面 [英] how to redirect a page in ajax
本文介绍了如何在ajax中重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
请为此问题提供解决方案
我在ajax中尝试了以下内容
window 。 location .ahref = dashboard.php;
但是这段代码不起作用。
当我采用url的总路径然后它正在工作,但我想只给出文件名..
请给出解决方案。
我的代码在这里
< script type = text / javascript>
$( document )。ready( function (){
$(< span class =code-string> #login)。click( function (){
username = $( #username)。val ();
密码= $( #password)。val();
$ .ajax({
type: POST,
url: logind.php,
data:{
user:username,
pass:password
},
success: function (msg){
if (msg == 0 ){
$ required.html( 用户名和密码错误.........)。对话框(' open');
}
else {
alert(msg);
window 。 location .ahref = dashboard.php;
}
}
});
return false ;
});
return true ;
});
< / script>
解决方案
( document ) .ready( function (){
( #login)。click( function (){
username =
( #username)。val();
password =
Hi friends,
Please give solution for this issue
I tried the following in ajax
window.location.ahref = "dashboard.php";
but this code not working.
When I take total path of url then it is working, but I want give only filename..
Please give solution for this.
My code is here
<script type="text/javascript">
$(document).ready(function(){
$("#login").click(function(){
username=$("#username").val();
password=$("#password").val();
$.ajax({
type: "POST",
url: "logind.php",
data: {
user: username,
pass: password
},
success: function(msg){
if(msg == 0) {
$required.html("username and password wrong.........").dialog('open');
}
else {
alert(msg);
window.location.ahref = "dashboard.php";
}
}
});
return false;
});
return true;
});
</script>
解决方案
(document).ready(function(){
("#login").click(function(){ username=
("#username").val(); password=
这篇关于如何在ajax中重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文