$.ajax({url:"csadd.do",
type:"post",
dataType:"json",
traditional: true,
data:{cs_date:cs_date,cs_name:cs_name,cs_df:cs_df,cs_kpxx:cs_kpxx,cs_sm:cs_sm},
success: function(msg) {
alert(msg);
if(msg=="Y"){
alert("添加成功");
}
}
});
PrintWriter pw = response.getWriter();
pw.print("Y");
pw.flush();
pw.close();
什么情况啊这是,后端也必须传json格式的吗?
求助》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
使用 console.log(msg); 看一下后台传来的数据是""还是根本没有传回来数据
肯定是jar包没有用对,,,自动解析json的包要加进去,如果是拼接起来的json数据,,你还是去control好好看看字符串里面是不是引号或者分号少了一个
返回Y又不是json对象,改数据类型为text或者html,同时增加error回调看服务器端是否有错误
dataType:"json",
===》
dataType:"text",
error:function(xhr){alert(xhr.responseText)},
....
alert(msg)应该可以弹出来的啊,你可以f12看看到底返回了什么
猜测有可能你禁用了弹出框,你百度下检查看看是不是禁用了弹出窗口