日期:2014-05-18  浏览次数:20689 次

请问各位高手javascript怎么得到ajax传到页面的值
function addUser()
{
var udiv=document.getElementById("udiv").value;
var pwd=document.getElementById("pwd").value;
alert(udiv);
alert(pwd); //总是显示undefined
}


<table class="query_form_table" border="0" cellPadding="3" cellSpacing="0">
<tr>
<th class="input_title">用户名</th>
<td class="input_content">
<input type="text" name="loginname" onblur="send_request()">
<div id="udiv" >
 
  </div>
</td>
</tr>
<tr>
<th class="input_title">密码</th>
<td class="input_content">
<input type="text" name="passwd">
</td>
</tr>
<tr>
<th class="input_title">确认密码</th>
<td class="input_content"><input type="text" name="passwd2" onblur="PDpassword()">
<div id="pwd"></div>
</td>
</tr>
<tr>
<th class="input_title">地区</th>
<td class="input_content">
<select name="area">
<% 
for(int i=0;i<arealist.size();i++)
{
Corarea area=(Corarea)arealist.get(i);
%>
<option id="<%=area.getId()%>"><%=area.getName()%></option>
<% }
%>

</select>
</td>
</tr>

</table>

------解决方案--------------------
http = new XMLHttpRequest();
var info = http.responseText;//info就是返回值