我的button按钮的onclick事件调用JS里的方法发生 is not defined 错误

shenhongfa 2015-10-25 12:14:36
js代码:
function cx(pi){
//职称名称
var pn_name = $("[name='hrm_positionName.pn_name']").val();
//所属部门id
var did = $("[name='hrm_positionName.hrm_dept.d_id']").val();
//是否启用id
var suid = $("[name='hrm_positionName.hrm_comAttribute_Son.son_id']").val();
//当前页
var pageIndex = 1;
if(pi!=null && pi!="")
var pageIndex = pi;

alert(pageIndex);

//post请求不能用这种参数链接形式
/* "hrm_positionName.pn_name='"+pn_name+"'&hrm_positionName.hrm_dept.d_id='"+did+"'&hrm_positionName.hrm_comAttribute_Son.son_id='"+suid+"'" */
$.post("queryPn.action",{"hrm_positionName.pn_name":pn_name,"hrm_positionName.hrm_dept.d_id":did,"hrm_positionName.hrm_comAttribute_Son.son_id":suid,"pageIndex":pageIndex},function(result){
var content = "";
for (var i=0;i<result.length;i++) {
content+="<tr><td>"+result[i].pn_coding+"</td><td>"+result[i].pn_name+"</td><td>"+result[i].hrm_dept.d_name+"</td><td>";
if(result[i].hrm_comAttribute_Son.com_son_name == "启用"){
content+="<input type='checkbox' name='ck' checked='checked'>";
}else{
content+="<input type='checkbox' name='ck'>";
}
content+="</td><td><a>修改</a>  <a>明细</a>  <a>删除</a></td></tr>";
};
$("#content").html(content);
});
};
















jsp代码:
<button class="btn btn-primary" onclick="cx(2);">下一页</button>
...全文
4716 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Mainづ鑫 2018-12-06
  • 打赏
  • 举报
回复
我这边也是 cx is not defined 各位大佬非常厉害
wflvjie 2018-12-04
  • 打赏
  • 举报
回复
是报的 cx is not defined 吧?
老乔9527 2018-11-30
  • 打赏
  • 举报
回复
cx = function (pi){
Iohannes 2017-11-16
  • 打赏
  • 举报
回复
因为你的js被包在$(document).ready(function(){}里面
liusaint1992 2015-10-25
  • 打赏
  • 举报
回复


我这边没有你说的问题哦,可以弹出来。用的这个jq: <script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>


你检查一下cx();这个里面有没有错误 。 看f12工具里有没有报错。

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧