Uncaught TypeError: Cannot read property 'value' of null
2016-02-16 12:23
986 查看
Uncaught TypeError: Cannot readproperty 'value' of null
一个js方法调用另一个js方法,另一个js方法调用不到页面节点值
由于前一个js方法访问action链接跳转,页面获取不到id参数值
解决办法:第二个方法调用第一个方法的值
如果直接在第二个方法中取id值会报错
一个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>
相关文章推荐
- Spark UI (基于Yarn) 分析与定制
- Android-节日短信送祝福(UI篇:1-主布局的基本实现)
- UICollectionView 简单使用
- 使用Core Animation优化UIKit性能
- poj 1458 Common Subsequence
- ngui一些场景切换的心得
- Negative value (-100) passed to setFirstResult
- ios:UIAlertView自动消失
- Java GUI做简易计算器
- Jenkins修改workspace和build目录
- 【CodeForces 339B】Red and Blue Balls 找规律
- The Only Technique To Learn Something New
- UITextView 实现placeholder的方法
- request getHeader("x-forwarded-for") 获取客户端IP地址
- UINavigationController 直接pop到指定controllerView的方法
- 基于MVC4+EasyUI的Web开发框架形成之旅--界面控件的使用
- Android开发学习之路--UI之简单聊天界面
- edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解
- Latex:IEEE会议模板中出现undefined control sequence \includegraphics问题解决方法
- 安卓蓝牙技术Bluetooth使用流程(Bluetooth详解)