首页 新闻 赞助 找找看

the method is not defined

0
[待解决问题]

js 文件wichandler.js:

function savewic() {
    var entity = getCurrentEntity();

    $.post({ .....
    }, 'json');
}

在index中定义getCurrentEntity 方法, 

<script type="text/javascript" >
function getCurrentEntity() {
    var entity = {
        Id: $('input[name="id"]').val(),
        Name: $('input[name="name"]').val(),
        Description: $('input[name="description"]').val()
    };
}
</script>

运行时调用getCurrentEntity时提示找不到该方法?小白一枚,请问怎么解决?

舒舞影的主页 舒舞影 | 菜鸟二级 | 园豆:202
提问于:2017-12-14 16:29
< >
分享
所有回答(2)
0

检查下getCurrentEntity和controller中对应的方法名一致吗?

起风了~~~ | 园豆:691 (小虾三级) | 2017-12-14 17:06
0

应该是你的加载的时机的问题,JS资源先加载,index页面的这个方法后加载,那肯定是找不到,你把这个方法放到哪个js里面去肯定可以找到的

哟,嘟嘟有糖☄⊙ω⊙ | 园豆:9 (初学一级) | 2017-12-15 14:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册