日期:2014-05-16  浏览次数:20914 次

ajax+php中get取得的url参数部分为空
url='login_chk.php?act='+(Math.random())+'&name='+$('lgname').value+'&pwd='+$('lgpwd').value;xmlhttp.open('get',url,true);
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readystate==4){
  if(xmlhttp.status==200){
  msg=xmlhttp.responseText;
  if(msg=='0'){
  alert('您还没有激活,请先登录邮箱进行激活操作。');
  }else if(msg=='1'){
  alert('用户名或密码输入错误,您还有2次机会');
  $('lgpwd').select();
  }else if(msg=='2'){
  alert('用户名或密码输入错误,你还有1次机会');
  $('lgpwd').select();
  }else if(msg=='4'){
  alert('用户名输入错误');
  $('lgname').select();
  }else if(msg=='-1'){
  alert('登录成功');
  location='main.php';
  }else{
  alert(msg);
  }  
  }
  }
}
xmlhttp.send(null);
}

login_chk.php
<?php
session_start();
header('Content-Type:text/html;charset=gb2312');
include_once 'conn.php';
$name=$_GET['name'];
$pwd=$_GET['pwd'];
print_r($_GET);

这里$pwd的值为空,$name不为空
请问是什么原因啊

------解决方案--------------------
如果你用了jquery
那么
$('#lgname').value

如果不是那么 document.getElementById('lgname')
哦明白了
看来你是自己写了个$函数是吧

那么你得确认 lgname 这个id有且是唯一的。