Ajax error:function(){}
<script type="text/javascript">
$().ready(function(){
var $submitButton = $("#submitButton");
$submitButton.click(function(){
check();
return false;
})
})
function check(){
var
username = $("#username").val();
$.ajax({
type:'POST',
url: '${base}/home/XXX.action',
data: 'username=' +
username,
dataType: 'json',
error : function() {
alert("数据库连接异常!");
},
success: function(data) {
alert(data.status);
}
})
}
</script>
</head>
<body>
<form:form>
<input type="text" name="username" id="username"/>
<input type="submit" value="提交" id="submitButton"/>
</form:form>
</body>
页面中红色的“username” 与蓝色的变量 “username” 相同时,程序只走error:function(){}
请问这是什么原因?
------解决方案--------------------function check(){
var username = $("#username").val();
$.ajax({
type:'POST',
url: '${base}/home/XXX.action',
data:{ "username":username},
dataType:'json',
error : function() {
&n