当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - ReferenceError: can't use function from external script - JS

问题描述:

I have been reading a few threads how to use function from external js scripts because there are few pages which will be using the same function but different params so I made a function but then doing it this way, I created one js file which has that function then adding the js into the html like this

(this is involving django-oscar)

in my html I used this to include the js and a function call that's in the js

<script type="text/javascript" src="{% static "js/add-cart-ajax.js" %} "></script>

<script>

$(function(){

fn();

})

</script>

as a testing in the js I only have

function fn(){

console.log("t");

}

I actually created a simple file without anything and seems to be working but why this isn't working in django-oscar?

I am really new with this, is there anything specific I should be looking for?

When I look at the source of the html in browser, the script is linked fine that it's not a broken link.

分享给朋友:
您可能感兴趣的文章:
随机阅读: