Uncaught TypeError: Cannot read property 'value' of null
来源:互联网 发布:软件系统架构设计 编辑:程序博客网 时间:2024/04/28 11:42
Uncaught TypeError: Cannot readproperty 'value' of null
一个js方法调用另一个js方法,另一个js方法调用不到页面节点值
由于前一个js方法访问action链接跳转,页面获取不到id参数值
解决办法:第二个方法调用第一个方法的值
$(document).ready(function() {var id=document.getElementById("courseid").value;$.ajax({type : 'post',url : 'http://localhost:8888/AMOOC/video_showDetail.action',contentType : 'application/x-www-form-urlencoded; charset=UTF-8',data : {id : id},success : function(data) {getPicture(id);},error : function erryFunction() {$("#div_course").html("error");}});});
function getPicture(id){$.ajax({type : 'post',url : 'http://localhost:8888/AMOOC/course_isFocused.action',contentType : 'application/x-www-form-urlencoded; charset=UTF-8',data : {id : id},success : function(data) {alert(data);},error : function erryFunction() {$("#div_course").html("error");}})};
如果直接在第二个方法中取id值会报错
function getPicture(){var id=document.getElementById("courseid").value;$.ajax({type : 'post',url : 'http://localhost:8888/AMOOC/course_isFocused.action',contentType : 'application/x-www-form-urlencoded; charset=UTF-8',data : {id : id},success : function(data) {alert(data);},error : function erryFunction() {}})};
</pre><pre>
0 0
- Uncaught TypeError: Cannot read property 'value' of null
- Uncaught TypeError: Cannot read property 'value' of null
- Uncaught TypeError: Cannot read property 'value' of null
- Uncaught TypeError: Cannot read property 'value' of undefined
- Uncaught TypeError: Cannot read property of 'name' null
- Uncaught TypeError: Cannot read property 'length' of null
- Uncaught TypeError: Cannot read property 'length' of null
- 【ExtJS】Uncaught TypeError: Cannot read property 'length' of null
- openlayers Uncaught TypeError: Cannot read property 'wrapDateLine' of null
- cocos2d-js-----Uncaught TypeError: Cannot read property 'style' of null
- Uncaught TypeError: Cannot read property 'getElementsByTagName' of null
- Uncaught TypeError: Cannot read property 'width' of null
- JavaScript:Uncaught TypeError Cannot read property 'id' of null。
- Uncaught TypeError: Cannot read property 'childNodes' of null
- Uncaught TypeError: Cannot read property 'offsetTop' of null
- js提示Uncaught TypeError: Cannot read property 'options' of null
- Uncaught TypeError: Cannot read property 'querySelector' of null
- Uncaught TypeError: Cannot read property 'hasOwnProperty' of null
- 全球半导体产值再创新高,2016年AOI设备需求热度有望保持
- 安全测试学习笔记一(Cookie&Session)
- IOS 开发 证书显示 此证书签发者无效 解决办法
- Hadoop 2.7.2
- textView 改变指定字体颜色
- Uncaught TypeError: Cannot read property 'value' of null
- Ubuntu环境下编译ACE
- (一)跑酷手游分析与部分功能实现
- NSLog的格式
- POJ-1860
- 算法导论之堆排序
- 将汉字转化为拼音
- MFC环境下Start&Pause&Stop操作
- 关于java发送邮件的一个示例