json出现异常
【急】json出现错误
------解决思路----------------------
写个普通的表单post到 yangzheng上,单独测试,看看返回的内容是不是对,
或者直接 F12, 用开发者工具跟踪一下 网络请求的返回数据
------解决思路----------------------
f12 调试下看报什么错误
------解决思路----------------------
那你就看看错误信息!
error:function(d){
alert(d);
}
------解决思路----------------------
alert(JSON.stringify(d));
下面的错误信息是说目标 url 没找到
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="<%=path%>/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(function () {
$("#Verify").click(function(){
$(this).attr("src","SecurityCodeImageAction?timestamp="+new Date().getTime());
});
});
$(document).ready(function(){
$("#button").click(function(){
var name= $('#id').attr('value');
if (name!=null||name!=""){
$.ajax({
url:"yangzheng",
type:"post",
dataType:"json",
success:function(data){
if(data.msg!=null){
$("#notsuccess").html(" <br>");
var html ="成功了" ;
$('#notsuccess').html(html);
}else{
$("#notsuccess").html(data.msg);
$("#notsuccess").css("color","red");
}
},
error:function(){
alert("出现错误");
}
});
}else{
alert("请填写用户名或密码");}
});
});
</script>
</head>
<body>
<form id="ids" action="yanzheng" name="form" method="post">
验证码:<input type="text" id="id" name="name" value="" />
<img src="SecurityCodeImageAction" id="Verify" style="cursor:hand;"/><font color="red">看不清?单击验证码</font>
<br/>
<div id="notsuccess"></div>
<input type="button" id="button" name="sbt" value="进入!"/>
</form>
</body>
</html>
------解决思路----------------------
写个普通的表单post到 yangzheng上,单独测试,看看返回的内容是不是对,
或者直接 F12, 用开发者工具跟踪一下 网络请求的返回数据
------解决思路----------------------
f12 调试下看报什么错误
------解决思路----------------------
那你就看看错误信息!
error:function(d){
alert(d);
}
------解决思路----------------------
alert(JSON.stringify(d));
下面的错误信息是说目标 url 没找到