iframe无法提交ajax的内容,无法经过后台

J2EE 码拜 8年前 (2016-09-17) 1257次浏览
前台代码:
var setting = {
data: {
simpleData: {
enable: true,
idKey: “id”,
pIdKey: “pid”,
rootPId: 0
}
},
callback: {
onClick: yonghuzTreeOnClick
}
};
$.post(“<%=request.getContextPath()%>/product/findZtree.action”,{id:1},function(obj){
$.fn.zTree.init($(“#prouser_tree”), setting, obj).expandAll(true);
},”json”);
后台代码:
@RequestMapping(“findZtree.action”)
@ResponseBody
public List<Dept> findZtree(){
System.out.println(“进来了”);
List<Dept> list =productService.findZtree();
for (Dept dept : list) {
System.out.println(dept);
}
return list;
}
经测试,后台不能接收前台的请求?为何会这样?


解决方案

70

直接访问<%=request.getContextPath()%>/product/findZtree.action这个路径~先看看能不能进入你的后台~可能是路径错了!

20

<%=request.getContextPath()%> 这个错了 你可以打出来看看这是什么
应该是
<%
String path = request.getContextPath();
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%>
url填这个试试
<%=basePath%>product/findZtree.action

10

引用:

@小爷胡汉三 在外边可以进去,就是在iframe框架中进不去~

路径没有问题的话~那就是你js导入的问题了应该!
你看看你的iframe里面有引入你ajax需要的js吗?


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明iframe无法提交ajax的内容,无法经过后台
喜欢 (0)
[1034331897@qq.com]
分享 (0)