I have this error and I don't understand why: ReferenceError: document is not defined.
I tried to put window.content.document, but error window is not defined too.
I don't know where is the trick and specially I don't understand why?
Worst when I take it off, I have as error ReferenceError: $ is not defined whereas I included jQuery in my html.
this is my script.js:
var client = {};
client.start = function (data) {
setTimeout(function(data) {
client.chart(data);
}, 60);
};
module.exports.getJson= function(data){
client.start(data);
};
client.chart= function (data) {
//console.log(" this is the data" + data);
$(document).ready(function() {
$(function () {
//Do my stuff
});
});
};
and my html:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/js/jquery-1.2.6.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/js/sprinkle.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div id="containerChart" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
</body>
</html>
Any ideas?
The proper answer, I believe, is that the linter you are using, does not know that you are running in a browser environment. Objects such as document and window are predefined. Personally, I had this issue with eslint and I fixed it by doing the following:
env: {
browser: true
}
Hope this helps somewhat.
You cannot have document object inside your script so remove below code from script.js
$(document).ready(function() {
$(function () {
//Do my stuff
});
});
Instead of above code, you can call your script function from html page like below
<script>
$(document).ready(function() {
//call your script.js function from here
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With