thinkphp与jquery

WBOY
Release: 2016-06-23 14:13:04
Original
1203 people have browsed it

thinkphp jQuery

页面代码为:
<form action="__URL__/login_in" method="post" name="form1">                    邮箱<input type="text" name="email" id="email" class="inpt"><span class="emailmsg"></span><br/>                    密码<input type="password" name="pwd" id="pwd" class="inpt"><span class="pwdmsg"></span><br/>                    <input type="button" value="" id="ulogin" class="log" >                </form>
Copy after login

jquery事件代码:
	$("#ulogin").click(function(){		$.ajax({			url:"./index.php/User/logincheck",			type:"POST",			data:{email:$("#email").val(),pwd:$("#pwd").val()},			//dataType:'text',			//timeout:1000,			error:function(){				alert('请求错误');				return false;			},			success:function(data){				$('.emailmsg').html(data);				//return false;			}		});	});
Copy after login

logincheck的方法如下:
public function logincheck(){
$email=$_POST['email'];
$pwd=md5($_POST['pwd']);
$user=M('User');
$list=$user->where('email=$email')->find();
if(empty($list)){
echo '该用户不存在';
exit;
}
$list=$user->where('email=$email and pwd=$pwd')->find();
if(empty($list)){
echo '密码错误';
exit;
}
}

因为在User模块里面有设置_empty()方法,所以每次点击后老是会出现_empty()方法中echo出的内容。哪位大神指导下!

回复讨论(解决方案)

把action= “”试试

把action= “”试试
还是不行

把你那ajax里的url写成绝对路径,

再不行那就真不行了。

为什么会出现空操作?LZ你怎么想?

能不能执行到你的logincheck方法?

Nice,不错的,收藏了

那个应该是action的问题,你改成绝对路径或者用:U(“***”)生成路径试试看

额,最后解决了。不知道mcleed的方法行不行,不过我只是把原来的url url:"./index.php/User/logincheck",改为方法名logincheck就行了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template