putting data into js vars

J

Jake

Hi,

I have the following javascript that receives data from a server-side
push technology. This function receives the data fine and is in an
external *.js file which I import in this web page.

data_event = function(data) {
var data_box = document.getElementById('data_output');
var div = window.parent.document.createElement('div');
div.className = "event";
div.innerHTML = data;
data_box.appendChild(div);
data_box.scrollTop = data_box.scrollHeight;
}

And also in this *.html page, I have the following where the data gets
printed as it arrives. And this works also.

<div id="data_output"></div>

But my problem is that, I want to fill in the data variables below (more
javascript in this same web page) and I don't know how to get it into
these dataX variables.

<script id="source" language="javascript" type="text/javascript">
$(function () {

var data1 = [[4, 8]];
var data2 = [[5, 2]];

// do plotting of data here ...
});
</script>

Can anyone lend a hand here? Any help much appreciated.
 
P

Peter Michaux

Hi,

I have the following javascript that receives data from a server-side
push technology. This function receives the data fine and is in an
external *.js file which I import in this web page.

data_event = function(data) {
var data_box = document.getElementById('data_output');
var div = window.parent.document.createElement('div');
div.className = "event";
div.innerHTML = data;
data_box.appendChild(div);
data_box.scrollTop = data_box.scrollHeight;

}

And also in this *.html page, I have the following where the data gets
printed as it arrives. And this works also.

<div id="data_output"></div>

But my problem is that, I want to fill in the data variables below (more
javascript in this same web page) and I don't know how to get it into
these dataX variables.

<script id="source" language="javascript" type="text/javascript">
$(function () {

var data1 = [[4, 8]];
var data2 = [[5, 2]];

// do plotting of data here ...
});
</script>

Can anyone lend a hand here? Any help much appreciated.

Perhaps you are looking for something like this

<URL: http://jibbering.com/faq/#FAQ4_18>

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,167
Latest member
SusanaSwan
Top