Saturday, May 25, 2024
 Popular · Latest · Hot · Upcoming
103
rated 0 times [  107] [ 4]  / answers: 1 / hits: 35055  / 9 Years ago, mon, march 23, 2015, 12:00:00

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?


More From » jquery

 Answers
8

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>

[#67341] Friday, March 20, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elliem

Total Points: 415
Total Questions: 117
Total Answers: 94

Location: American Samoa
Member since Fri, Aug 26, 2022
2 Years ago
;