Javascript 值为数字时,JSON返回未定义错误
我不确定我试图实现的目标中的错误在哪里 我正在使用其他人的代码,不幸的是,他们在某些地方使用数字作为div id 这些数字标识在不同的地方使用,如果可以的话,我想找到一种保持事物原样的方法 所以 在JSON中返回以下内容:Javascript 值为数字时,JSON返回未定义错误,javascript,php,jquery,json,ckeditor,Javascript,Php,Jquery,Json,Ckeditor,我不确定我试图实现的目标中的错误在哪里 我正在使用其他人的代码,不幸的是,他们在某些地方使用数字作为div id 这些数字标识在不同的地方使用,如果可以的话,我想找到一种保持事物原样的方法 所以 在JSON中返回以下内容: editorID: "1000" 在我的AJAX调用中,我使用如下返回: var editorID = response.editorID; CKEDITOR.instances.editorID.insertHtml('<br><img class="
editorID: "1000"
在我的AJAX调用中,我使用如下返回:
var editorID = response.editorID;
CKEDITOR.instances.editorID.insertHtml('<br><img class="buildimage" src="http://www.buildsanctuary.com/phpLibs/bulletproof-master/src/userBuildImages/'+response.imageName+'"><br>');
这给了我正确的值
当我尝试将一个数字直接放入CKEditor insertHTML代码时,它显示了我的语法错误,所以可能这就是问题所在。如果有,有什么解决办法吗
谢谢。Craig.要将变量用作属性,必须使用
[]
符号:
CKEDITOR.instances[editorID].insertHtml('<br><img class="buildimage" src="http://www.buildsanctuary.com/phpLibs/bulletproof-master/src/userBuildImages/'+response.imageName+'"><br>');
怎么样
CKEDITOR.instances[editorID]
?很好,现在我明白了:)
CKEDITOR.instances[editorID].insertHtml('<br><img class="buildimage" src="http://www.buildsanctuary.com/phpLibs/bulletproof-master/src/userBuildImages/'+response.imageName+'"><br>');
CKEDITOR.instances['1000'].insertHtml('<br><img class="buildimage" src="http://www.buildsanctuary.com/phpLibs/bulletproof-master/src/userBuildImages/'+response.imageName+'"><br>');