首页 新闻 赞助 找找看

ajax不执行

0
悬赏园豆:20 [已解决问题] 解决于 2014-07-10 10:18

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String param = request.getParameter("param");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title></title>
<meta http-equiv="cache-control" content="utf-8">
<!--<script type="text/javascript" src="<%=basePath %>js/verifyCode.js"></script>-->
<!--<script type="text/javascript" src="<%=basePath %>js/login.js"></script>-->
<link charset="utf-8" rel="stylesheet" href="<%=basePath %>css/ListStyles.css" media="all" />
<link charset="utf-8" rel="stylesheet" href="<%=basePath %>css/jquery.validate.css" media="all" />
<script type="text/javascript" src="<%=basePath %>js/jquery-1.6.4.js"></script>
<script type="text/javascript" src="<%=basePath %>js/jquery.validate.js"></script>
<script type="text/javascript" src="<%=basePath %>js/jquery.metadata.js"></script>
<script type="text/javascript" src="<%=basePath %>js/jquery.validate.messages_cn.js"></script>
<script type="text/javascript">
//重载窗口
function resetwindow(){
if(top.location != self.location){
top.location.href = self.location.href;
return true;
}
}
$().ready(function() {
$("#form").validate();
});
//判断用户密码是否正确或是否被禁用
function checksubmit()
{
//得到值
var chain_no=$("#chain_no").val();
var pwd=$("#user_password").val();
var user_id=$("#user_id").val();
$.ajax({
type: "POST",
url:"<%=basePath %>AjaxUpdate/AjaxUpdate_ajaxselectuserInfo",
data:"conditionKey="+chain_no+"&conditionValue="+pwd+"&key="+user_id,
success:function(message){
//判断
if(message=="成功"){
$("#form").submit();
}else{
alert(message);
}
}
});
}
</script>
</HEAD>

<body class="bdLogin" style="background-image:url(<%=basePath %>image/login/login_bg1.gif);" id="body" leftMargin="0" topMargin="0" MS_POSITIONING="GridLayout" onload="return resetwindow();">

<form name="form" method="post" action="<%=basePath%>Login/Login_Main" id="form">
<TABLE id="LoginTable" cellSpacing="0" style="margin-top:100px;" cellPadding="0" width="726" align="center" bgColor="#ffffff"
border="0">
<TR>
<td>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<IMG height="70" alt="" src="<%=basePath %>image/login/login_bg8.gif" width="405">
</td>
<td style="height:70px; padding-right:10px;background-image:url('<%=basePath %>image/login/login_bg9.gif');background-repeat:no-repeat" width="321" align="right" valign="top" >
<div style="line-height:20px"></div>
</td>
</tr>
</table>
</td>
</TR>
<TR>
<TD>
<TABLE id="Table2" cellSpacing="0" cellPadding="0" width="100%" align="center" border="0">
<TR>
<TD width="5" background="<%=basePath %>image/login/login_bg10.gif"></TD>
<TD vAlign="top">
<TABLE id="Table3" cellSpacing="0" cellPadding="0" width="100%" background="<%=basePath %>image/login/login_bg2.gif" style="background-repeat:no-repeat;"
border="0">
<TR>
<TD vAlign="top" colSpan="5" height="258" background="<%=basePath %>image/login/login_bg2.gif">
<%if(param==null){%>
<div id="info" class="error-box" style="display:none"></div>
<%}else if(param.equals("error")){%>
<div id="info" class="error-box" align="center"><font color="red">未登录或账号密码错误</font></div>
<%}%>
<TABLE id="Table5" cellSpacing="0" cellPadding="0" width="100%" border="0" style="font-size:12px;">
<TR>
<TD bgColor="#037ad9" height="1">
</TD>
</tr>
<TR>
<TD id="tdLoginList" vAlign="top" background="login_bg12.gif" height="156">
<TABLE id="Table6" height="100%" cellSpacing="0" cellPadding="0" width="98%" align="center" border="0" style="font-size:12px;">
<TR class="hide" id="trBranchNo">
<TD height="25" colspan="2" align="center">
欢迎使用后台管理系统
</TD>
<!--
<TD vAlign="middle" height="25">
<SELECT id="iid" name="iid" style="width:164px">
<s:iterator id="info" value="identitys">
<option value="${info.id}">${info.name}</option>
</s:iterator>
</SELECT>
</TD>
-->
</TR>
<TR class="hide" id="trDebitCardNo">
<TD style="WIDTH: 30%" vAlign="middle" align="center">
连锁编号:
</TD>
<TD vAlign="middle" height="25">
<input type="text" id="chain_no" name="loginDTO.chain_no" style="width:170px" class="{required:true,digits:true}">
</TD>
</TR>
<TR class="hide" id="trDebitCardNo">
<TD style="WIDTH: 30%" vAlign="middle" align="center">
账户编号:
</TD>
<TD vAlign="middle" height="25">
<input type="text" id="user_id" name="loginDTO.user_id" style="width:170px" class="{required:true,digits:true}">
</TD>
</TR>
<TR class="hide" id="trDebitCardQueryPwd">
<TD style="WIDTH: 30%" vAlign="middle" align="center">账户密码:</TD>
<TD vAlign="middle" height="25">
<TABLE height="100%" cellSpacing="0" cellPadding="0" width="100%" align="center" border="0">
<TR>
<TD width="105">
<input type="password" id="user_password" name="loginDTO.user_password" style="width: 170px">
<input type="hidden" name="loginDTO.user_type" value="1"/>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<!-- <TR class="hide" id="trExtraPwd">
<TD style="WIDTH: 30%" vAlign="middle" align="center">校验码:</TD>
<TD vAlign="middle" height="25">
<div class="fn-clear">
<input type="text" style="width: 64px"
class="i-text i-text-authcode ui-input sl-checkcode-input"
id="rand" name="rand" value="" maxLength="4" />
<img id="imgObj" onclick="changeImg();"
class="checkcode-img J-checkCode sl-checkcode-img"
src="<%=basePath %>images/code.gif"
title="点击图片刷新校验码" alt="点击图片刷新校验码" style="vertical-align:middle;cursor:pointer;width: 100;" />
</div>
</TD>
</TR>
-->
</TABLE>
</TD>
</TR>
<TR>
<TD id="tdLoginButton" vAlign="top" align="center" background="<%=basePath %>image/login/login_bg12.gif"
height="23">
<TABLE id="Table7" cellSpacing="0" cellPadding="0" width="174" align="center" border="0">
<TR>
<TD></TD>
<TD vAlign="top" align="center" width="50%">
<input id="com-submit" class="btnlong" type="button" onclick="checksubmit();" value="登录" />
</TD>

</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD background="login_bg13.gif" height="2"></TD>
</TR>
<TR class="hide" id="trDebitCardList">
<TD vAlign="middle" height="18">
</TD>
</TR>
<TR class="hide" id="trNetBankListBG">
<TD background="<%=basePath %>image/login/login_bg13.gif" height="2"></TD>
</TR>
<TR>
<TD id="tdContentList" vAlign="bottom" height="50">
<TABLE id="Table8" cellSpacing="0" cellPadding="0" width="100%" align="center" border="0">
<TR id="trDebitCardRelFunc" style="DISPLAY: block;font-size:12px;">
<TD colSpan="2"></TD>
<TD colSpan="3" height="20">
</TD>
<TD width="5"></TD>
</TR>
<TR>
<TD width="15"></TD>
<TD width="10"></TD>
<TD class="hui" width="105" height="25"></TD>
<TD width="108">
</TD>
<TD>&nbsp;</TD>
<TD width="5"></TD>
</TR>
<TR>
<TD colSpan="5" height="8"></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
<TD vAlign="top" width="461">
<TABLE id="Table12" cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR>
<TD vAlign="top" align="right" width="461" height="258">
<img width="100%" height="100%" src="<%=basePath %>image/login/wd_adv.jpg"/>
</TD>
<TD height="258"></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD width="726" height="36">
<table id="tblMessageList" border="0" cellSpacing="0" cellPadding="0" width=100% height=36 background="<%=basePath %>image/login/login_bg7.gif">
<tr>
<TD height=13 align=left colspan=3></td>
</tr>
<tr>
<TD height=20 align=left width=400 style="font-size:12px;color:#fff;">

</TD>
<TD align=left valign=top>
</TD>
<TD></TD>
</tr>
<tr>
<TD height=1 align=left colspan=3></td>
</tr>
</table>
</TD>
</TR>
</TABLE>
</form>
</body>
</HTML>

 

 

为什么我点击登录按钮,他不会执行ajax请求;而且alert(message)输出的还是上一个页面的所有的html的代码!!!

光标下的世界的主页 光标下的世界 | 初学一级 | 园豆:34
提问于:2014-07-09 17:58
< >
分享
最佳答案
0

能到 alert(message); ajax不就执行?

收获园豆:10
Yu | 专家六级 |园豆:12980 | 2014-07-09 20:41

可他跟本没有进入到路劲指定的后面去!知道原因不?

光标下的世界 | 园豆:34 (初学一级) | 2014-07-10 07:44

@光标下的世界: 那可能 url  不对 , 你试试

 

var url= "<%=basePath %>AjaxUpdate/AjaxUpdate_ajaxselectuserInfo";

alert(url) ;

Yu | 园豆:12980 (专家六级) | 2014-07-10 08:24

@Yu: 路径是对的啊!

光标下的世界 | 园豆:34 (初学一级) | 2014-07-10 08:33

@Yu: 那你用 Fiddler 工具调试一下吧 

Yu | 园豆:12980 (专家六级) | 2014-07-10 08:40
其他回答(2)
0

调式一下Js,看看报什么异常。

收获园豆:5
晓菜鸟 | 园豆:2594 (老鸟四级) | 2014-07-10 08:52

怎么调试js啊?使用IE可以吗?

支持(0) 反对(0) 光标下的世界 | 园豆:34 (初学一级) | 2014-07-10 08:53

@光标下的世界: 建议使用火狐或者谷歌,不过使用火狐得安装一个FireBug插件,谷歌就不用了,F12可以对JS打断点进行调式。

支持(0) 反对(0) 晓菜鸟 | 园豆:2594 (老鸟四级) | 2014-07-10 09:13
0

你是什么版本的IE,IE9之后有F12的调试器。

要不,你装个FireFox,然后在安装FireBug组件,就可以调试JS了。

收获园豆:5
Alex_QY1987 | 园豆:1888 (小虾三级) | 2014-07-10 09:09

好,谢谢!

支持(0) 反对(0) 光标下的世界 | 园豆:34 (初学一级) | 2014-07-10 09:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册