对于console输出:xxx is not defined or is not a function的解析
2017-07-17 18:37
429 查看
1、如果console输出信息为“m is not defined”:
可能的问题是:m这个对象不存在,或者在用类或者id引用这个对象的时候,类名或者id名写错了。直白点就是要么该对象不存在, 要么是没有正确引用到该对象
2、要是console输出信息是“ nnn is not a function ”,
但是在别的地方对nnn()的引用却是成功的,这有可能是在引用这个函数的时候,写函数的参数没有写对,比如:
定义函数:nnn(m,b,fuction(){}),定义函数ff(){};
引用函数的时候写成nnn(1,ff(){}); 这时候console就会报错,“nnn is not a function”
正常引用是这样的:nnn(1,2,ff(){});
3、html中有时候不能加载函数:console会输出mmm is not a function
例如声明函数式:function(node){
var node_id = node.id;
var activ_id = node_id.substr(6,node_id.length-6);
var url = globalConfig.pre_url + "/wxwall_api/activity/handle_activity.php";
var data = {"user_id" : user_id,"activity_id":activ_id, "status" : "2" };
request(url,data,function(response){
alert(response.msg);
location.reload();
});
}
就会报上面的问题
如果改成函数表达式就没有问题:handle_activity = function(node){
var node_id = node.id;
var activ_id = node_id.substr(6,node_id.length-6);
var url = globalConfig.pre_url + "/wxwall_api/activity/handle_activity.php";
var data = {"user_id" : user_id,"activity_id":activ_id, "status" : "2" };
request(url,data,function(response){
alert(response.msg);
location.reload();
});
}
可能的问题是:m这个对象不存在,或者在用类或者id引用这个对象的时候,类名或者id名写错了。直白点就是要么该对象不存在, 要么是没有正确引用到该对象
2、要是console输出信息是“ nnn is not a function ”,
但是在别的地方对nnn()的引用却是成功的,这有可能是在引用这个函数的时候,写函数的参数没有写对,比如:
定义函数:nnn(m,b,fuction(){}),定义函数ff(){};
引用函数的时候写成nnn(1,ff(){}); 这时候console就会报错,“nnn is not a function”
正常引用是这样的:nnn(1,2,ff(){});
3、html中有时候不能加载函数:console会输出mmm is not a function
例如声明函数式:function(node){
var node_id = node.id;
var activ_id = node_id.substr(6,node_id.length-6);
var url = globalConfig.pre_url + "/wxwall_api/activity/handle_activity.php";
var data = {"user_id" : user_id,"activity_id":activ_id, "status" : "2" };
request(url,data,function(response){
alert(response.msg);
location.reload();
});
}
就会报上面的问题
如果改成函数表达式就没有问题:handle_activity = function(node){
var node_id = node.id;
var activ_id = node_id.substr(6,node_id.length-6);
var url = globalConfig.pre_url + "/wxwall_api/activity/handle_activity.php";
var data = {"user_id" : user_id,"activity_id":activ_id, "status" : "2" };
request(url,data,function(response){
alert(response.msg);
location.reload();
});
}
相关文章推荐
- Android JS桥交互("Uncaught ReferenceError: xxx is not defined or xxx has no method")
- python中input输出“Name 'XXX' is not defined问题
- XXX cannot be resolved or is not a field
- 手动删除webapps下项目,导致Document base %TOMCAT_HOME%\webapps\XXX does not exist or is not a readable directory
- sql --it is not contained in either an aggregate function or the GROUP BY clause.
- ERROR Configuration variable JAVA_HOME or JAVACMD is not defined correctly
- 解决Jquery Kendo.xxx is not a function 的方法
- jsp中引用自定义的js方法时:XXX is not defined
- warning:reset()[function.reset]:passed variable is not an array or object
- TypeError: $(...).dataTable is not a function 或 jQuery is not defined
- jQuery问题:$XXX is not a function
- ERROR 1336 (0A000): Dynamic SQL is not allowed in stored function or trigger
- (转)TOMCAT JAVA_HOME or JRE_HOME environment variable is not defined correctly(2013-03-29 13:04:14)
- jsp引入bootstrap、bootstrap-Validator后出现xxx is not a function的问题及解决办法!
- js 函数报错“Uncaught: TypeError xxx is not a function”
- builtin function or method object is not subscriptable
- matlab错误:Function 'conv2' is not defined for values of class 'double' and attributes
- jsp中引用自定义的js方法时:XXX is not defined
- (转)Version 0 is not defined for fiscal year 2XXX
- invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause