解决方案 »
- if(document.form1.cb[i].checked) 不明白什么意思?
- xmlhttprequest.open中的url能调用外网吗?如百度什么的。
- 控制单选按钮选中问题
- javascript乱码用jquery实现的
- 关于使用框架网页刷新的问题?
- 求一段JS,大侠们帮忙,毕业设计,急急急...
- 关于框架和iframe的问题
- 如何自定义cursor的图形?我想用一个小图片来代替默认的cursor。
- 如何制作一个能弹出的层?
- 插入FLASH动画后用javascript写的雪花动画为什么只出现在flash动画的后面。
- ext3.1 Ext.grid.EditorGridPanel修改完数据怎样刷新页面
- 新人发帖求助!!!highcharts export image 中文乱码解决方案
if(data=='exist'){
$('#accounthint').html('<p>该账号已经存在</p>');
}
else $(this).html('<p>该账号可以使用</p>');
}
加上了以后还是没有反应T T
在action里面加上一个输出语句,也没有被执行。为什么没有进到action呢?
加上了还是不行 T T后台方法前面有加[HttpGet]么
1、$.get()中的第一个参数URL,不知道是你那么设置的还是我没接触到,我用的SpringMVC,Struts2都快忘了,action有那么长吗=、=,要是我直接就CheckAccountName.action
2、URL后边应该没有“?”吧,如果用问号,可以就
$.get('src/struts/action/CheckAccountName.action?userid = '+ account,了第二个参数就省了
3、第三个参数,我没这么写过,一般都是function(data) {},如果你拆开写的话,调用这个JS后边应该加括号吧?processData(data);
如果还没用的话,用火狐浏览器FireBug追一下吧 应该会有错误,看看到底是哪出毛病了
加上了还是不行 T T后台方法前面有加[HttpGet]么没有求解释怎么写。。
另外,那返回的时候也需要http write这样的函数吗?
嗯 还是建议先Firebug看一下,排除一下是否是JS的问题
加上了还是不行 T T后台方法前面有加[HttpGet]么没有求解释怎么写。。
另外,那返回的时候也需要http write这样的函数吗?
1、就在方法前面加一个 [HttpGet] 这个表示GET方式访问的方法,记得默认的是post样
2、直接返回值就可以了
document.getElementById("accounthint").innerHTML = "";
}
function verify(){
var newXHR;
createXmlHttp();
var userid = document.getElementById('accountname').value;
if(userid=='') document.getElementById('accounthint').innerHTML="用户名不能为空";
newXHR.onreadystatechange = responseTo;
newXHR.open('GET','CheckAccountName_check?userid=' + userid,true);
newXHR.send(null);
window.alert(newXHR.responseText);
}
function createXmlHttp(){
if(window.XMLHttpRequest){
newXHR = new XMLHttpRequest();
}else{
newXHR = new ActiveXObject("Microsoft.XMLHttp");
}
}
function responseTo(){
if (newXHR.readyState==4){
var response = newXHR.responseText;
if(response=="exist")
document.getElementById("accounthint").innerHTML = "用户名已经存在";
else{
document.getElementById("accounthint").innerHTML = "恭喜您,可以使用";
}
}
}
<td width="13%" height="38" class="top_hui_text"><span class="login_txt">帐号: </span> </td>
<td height="38" colspan="2" class="top_hui_text"><input name="account.userid" id="accountname"
onblur="verify()" onfocus="clear()" class="editbox4" value="" size="20"> public String check() throws IOException{
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
response.setHeader("Charset","UTF-8");
try{
PrintWriter out = response.getWriter();
out.print("exist");
System.out.println("it is here");
out.flush();
out.close();
//result = am.checkAccountName(this.userid);
}catch (IOException e){
e.printStackTrace();
}
return null;
}
这是现在的三段代码,但是界面上只能反映为空的情况,还是不能比较是不是存在,
我已经把action拿出来了,直接返回一个存在,但是还是没反应,为什么啊?
你这都都错了把action?后面的','去掉
谢谢了。。