Rails和ajax文件上传 - 无法读取属性'innerHTML'的null错误 [英] Rails and ajax file upload - cannot read property 'innerHTML' of null error
问题描述
我正在开发一个带有动态模块的Rails应用程序 - ajax - 图像上传到图库。我是在这个应用程序 - 多文件上传 - 演示的基础上做的。我不是很喜欢Javascript和东西,所以我从该实现中复制了很多逻辑。
I am developing a Rails app with a module for dynamic - ajax - image upload to gallery. I am doing it basing on this app - multi-file-upload-demo. I am not very keen in Javascript and stuff, so I copy a lot of logic from that implementation.
我按照rounders demo的所有逻辑构建了我的应用程序,我有包括所有宝石和JavaScript库,我收到一个错误:
I made up my app following all logic from rounders demo, I have included all gems and javascript libraries, and I get an error:
Uncaught TypeError: Cannot read property 'innerHTML' of null
镀铬控制台中的
,指的是tmpl.js文件
in chrome console, which refers to tmpl.js file
tmpl.load = function (id) {
return document.getElementById(id).innerHTML;
};
我对JS的了解并没有让我明白哪一段代码触发了这个功能所以我可以走得更远。
My knowledge of JS doesn't make it clear to me which piece of code triggers that function so I can go further.
您能告诉我下一步调查此问题的来源是什么?我预计潜在的原因可能会有所不同,所以我不想粘贴应用程序中的所有代码。
Can you advise me what are the next steps to investigate source of this problem? I expect potential reasons may be various, so I don't want to paste all code from the application.
推荐答案
这是旧的但我找到了一个实际的解决方案。将 application.js
中的需求更改为 // = require jquery-fileupload / basic
而不是 // = require jquery-fileupload
。
This is old but I found an actual solution to this. Change your require in application.js
to //=require jquery-fileupload/basic
instead of //= require jquery-fileupload
.
这篇关于Rails和ajax文件上传 - 无法读取属性'innerHTML'的null错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!