jquery.ajax请求action时 回调函数不执行
JSP页面:—————————————————————————————————————————<html><head><scripttype="text/javascri...
JSP页面:
—————————————————————————————————————————
<html>
<head>
<script type="text/javascript" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript">
$(function(){
$("#submit").click(function(){
$.ajax({
type:"post",
dataType:"json",
url:"auditcustomer",
data:"customerid="+$('p').text()+"&checked="+$('select').val(),
success:function(data){
alert("success");
},
error:function(data){
alert("fail");
}
});
});
});
</script>
</head>
<body>
<p><%=customer.getCustomerId() %></p> <br>
<SELECT id="select" >
<OPTION value="1">通过</OPTION>
<OPTION value="0">未通过</OPTION>
</SELECT>
<div><input id='submit' type=button value="submit"></div>
</body>
</html>
————————————————————————————————
Action类:
——————————————————
public class CustomerAuditAction extends ActionSupport {
private String customerid;
private String checked;
public String AuditCustomer(){
customerauditdao.auditCustomer(customerid,checked);//执行数据库操作
return SUCCESS;
}
}
————————————————————————
Struts配置:
————————————————————————
<package name="" extends="struts-default" namespace="/">
<action name="auditcustomer" class="com.action.CustomerAuditAction" method="AuditCustomer">
<result name="success" ></result>
</action>
</package>
————————————————————————————
Action里数据库操作能正常执行,执行完以后返回给前台 不执行成功的回调函数,即不执行alert("success").在firedebug里报下面的错误:
HTTP Status 404 - result 'null' not found
type Status report
message result 'null' not found
description The requested resource (result 'null' not found) is not available. 展开
—————————————————————————————————————————
<html>
<head>
<script type="text/javascript" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript">
$(function(){
$("#submit").click(function(){
$.ajax({
type:"post",
dataType:"json",
url:"auditcustomer",
data:"customerid="+$('p').text()+"&checked="+$('select').val(),
success:function(data){
alert("success");
},
error:function(data){
alert("fail");
}
});
});
});
</script>
</head>
<body>
<p><%=customer.getCustomerId() %></p> <br>
<SELECT id="select" >
<OPTION value="1">通过</OPTION>
<OPTION value="0">未通过</OPTION>
</SELECT>
<div><input id='submit' type=button value="submit"></div>
</body>
</html>
————————————————————————————————
Action类:
——————————————————
public class CustomerAuditAction extends ActionSupport {
private String customerid;
private String checked;
public String AuditCustomer(){
customerauditdao.auditCustomer(customerid,checked);//执行数据库操作
return SUCCESS;
}
}
————————————————————————
Struts配置:
————————————————————————
<package name="" extends="struts-default" namespace="/">
<action name="auditcustomer" class="com.action.CustomerAuditAction" method="AuditCustomer">
<result name="success" ></result>
</action>
</package>
————————————————————————————
Action里数据库操作能正常执行,执行完以后返回给前台 不执行成功的回调函数,即不执行alert("success").在firedebug里报下面的错误:
HTTP Status 404 - result 'null' not found
type Status report
message result 'null' not found
description The requested resource (result 'null' not found) is not available. 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询