Maison >développement back-end >tutoriel php >注册页面对应的函数得不到文本控件的值
注册页面对应的函数:
$.post('{:U("Register/register")}', $('#register'), function(str) { // .serialize()
//注册 public function register() { $data['u_username'] = strtolower(I('name', '', 'trim')); $data['u_phone'] = I('phone', '', 'trim'); $data['u_email'] = I('email', '', 'trim'); $data['u_password'] = I('pass'); $data['repassword'] = I('rpass'); $rpass = I('rpass'); ... ...
if (email === 0 || phone === 0 || code === 0 || username === 0 || password === 0 || rpassword === 0) {...
if (document.getElementById("email").value === 0 || document.getElementById("phone").value === 0 || document.getElementById("code").value === 0 || document.getElementById("username").value === 0 || document.getElementById("password").value === 0 || document.getElementById("rpassword").value === 0) {
<input name="email" id="email" maxlength="30" />
如果 register 是表单的id
那么
$.post('{:U("Register/register")}', $('#register') .serialize(), function(str) { .......
是THINKPHP框架的项目噢!
如果 register 是表单的id
那么
$.post('{:U("Register/register")}', $('#register') .serialize(), function(str) { .......
这是为什么呢?
别的类似的ajax都触发了,为什么这句AJAX无法被触发呢?百思不得其解!
前面说得不对,有触发AJAX,返回这个怪怪的字符串,也不知道哪里来的: {"info":"\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef!","status":0,"url":""}
应该返回1或“注册失败,请重试!”才对啊!奇怪!
if ($status && $status2 && $status1 && $status3) { $m->commit(); unset($_SESSION['thirdPartyUserId']); unset($_SESSION['thrid_party_type']); $_SESSION['uname'] = $data['u_username']; die("1"); } else { $m->rollback(); die("注册失败,请重试!"); }
print_r(json_decode(' {"info":"\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef!","status":0,"url":""}'));
stdClass Object
(
[info] => 验证码输入错误!
[status] => 0
[url] =>
)
你没按规矩来!