如何重定向到$就完整视图 - asp.net MVC 3 [英] how to redirect to a view on $.AJAX complete - asp.net mvc 3
问题描述
Ok..i要使用$阿贾克斯到peritcular查看验证检查后,将用户重定向...我该怎么办呢? .. pleae帮助...
Ok..i want to redirect a user after the validation check using $.AJAX to a peritcular view... how do i do that ? .. pleae help...
这是我的$阿贾克斯code ... EX:我想用户重定向到/首页/电影控制器动作...
here is my $.AJAX code... EX: i want user redirected to "/Home/Movies" controller action...
如果没有登录停留在同一页上...
if not logged in stay on the same page...
<script type="text/javascript">
$('#btnLogin').click(function () {
var email = $('#Email').val();
var Password = $('#Password').val();
var postdata =
{
"Email": email,
"Password": Password
};
$('.Loading').fadeIn(50);
$.ajax({
url: '@Url.Action("CheckLogin","Home")',
data: postdata,
success: function (msg) {
var data = msg.split(':');
$('#Result').html(data[0]);
$('.Loading').fadeOut(50);
},
error: function (data) {
$('#Result').html(data);
$('.Loading').fadeOut(50);
}
});
});
</script>
下面是用于检查详情登陆我的控制器动作...
here is my controller action which is used for checking Login details...
public ContentResult CheckLogin(Users checkuser)
{
if (db.CheckUserLoginDetails(checkuser.Email, checkuser.Password))
{
return Content("Login Successful:" + checkuser.Email);
}
else
{
return Content("Login UnSuccessful");
}
}
还怎么能传递一个返回的结果从该视图另一种观点。在这种〔实施例,如果用户登录我想说明重定向页面这是对他的电子邮件ID可以说/家庭/短片
also how can i pass a returned results from this view to another view.. in this exmaple if the user is logged in i want to show his email id on the redirected page which is lets say "/home/Movies"
THX提前
推荐答案
显示Ajax请求之前,您加载图片,并隐藏在成功
或错误
处理程序。
Show your loading image before ajax request, and hide on success
or error
handlers.
添加&LT; DIV CLASS =加载&GT;加载...&LT; / DIV&GT;
来您的标记
$('.loading').fadeIn(50);
$.ajax({
url: '@Url.Action("CheckLogin","Home")',
data: postdata,
success: function (msg) {
$('#Result').html(msg);
$('.loading').fadeOut(50);
},
error: function (data) {
$('#Result').html(msg);
$('.loading').fadeOut(50);
}
});
这篇关于如何重定向到$就完整视图 - asp.net MVC 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!