获取"TypeError: invalid 'in'操作数a"在WordPress
Getting a "TypeError: invalid 'in' operand a" within WordPress
所以我得到一个TypeError:无效的'in'操作和WordPress内的错误(不确定这是否与之相关),我不确定代码有什么问题。
下面是问题代码:
e_jsonObj = [];
$.each(the_wpcc_posts, function(i, the_wpcc_post) {
var e_post_id = the_wpcc_post[i].ID;
var e_title = the_wpcc_post[i].post_title;
var e_start = the_wpcc_post[i].post_date_gmt;
e_item = {}
e_item ["id"] = e_post_id;
e_item ["title"] = e_title;
e_item ["start"] = e_start;
console.log(e_item);
e_jsonObj.push(e_item);
});
尝试在each
循环之前解析数据。似乎你正在尝试迭代一个字符串,这导致了这个错误。
e_jsonObj = [];
data = $.parseJSON(the_wpcc_posts); // parsing data
$.each(data, function(i, the_wpcc_post) {
var e_post_id = the_wpcc_post[i].ID;
var e_title = the_wpcc_post[i].post_title;
var e_start = the_wpcc_post[i].post_date_gmt;
e_item = {}
e_item ["id"] = e_post_id;
e_item ["title"] = e_title;
e_item ["start"] = e_start;
console.log(e_item);
e_jsonObj.push(e_item);
});
相关文章:
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- 在wordpress一定时间后更改自定义字段
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 如何使MailHandler.php在Wordpress中工作
- 使用“+="操作人员
- //而不是在src=“”上使用http://"属性
- "未捕获的语法错误:意外的标记}"
- Wordpress插件根据需要加载js和css
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "实例范围”;TypeScript类的getter/setter
- 无法再创建Wordpress页面
- Javascript复选框函数:;缺少:在属性id之后"
- "“;变量未引用正确的对象
- Wordpress中带有JQuery Accordion的未定义匿名函数
- 如何在Wordpress文件中添加自定义javascript代码"single.php”;
- "如果元框为空“;从前端隐藏它-WordPress
- Wordpress Testimonials"未捕获错误”;
- "添加媒体”;升级到Wordpress 3.9后按钮不工作