Changeset 16574
- Timestamp:
- 06/02/13 12:50:14 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/js/xmlrequest.js
r16573 r16574 1 function testData() 2 { 3 //calls the xml request in a loop based on the current sources 4 var source = ['Mrk 421','Mrk 501']; 5 for (i = 0; i<source.length; i++) { 6 testXMLData(i, source); 7 } 8 } 9 10 function testXMLData(index, source) 11 { 12 var testXML; 13 testXML = new XMLHttpRequest(); 14 //NOTE: previous errors on the request was caused by appending "http://www.fact-project.org" 15 testXML.open("GET","/smartfact/index.php?source="+escape(source[index])+"&time="+year+"-"+month+"-"+day,true); 16 dataSource = new Array(); 17 testXML.onload=function() { 18 if (testXML.status==200) 19 { 20 line=testXML.responseText.split('\n'); 21 dataSource.push(line); 22 if (dataSource.length == source.length) 23 displayXMLData(dataSource, source); //this will be called when the last data from the list is read 24 } 25 testXML.send(); 26 } 27 28 function displayXMLData(dataSource, source) 29 { 30 //This function splits the lines of data per data source 31 var dataGraph = new Array(source.length); 32 for (i=0; i<source.length; i++) { 33 dataGraph[i] = new Array(); //dataGraph contains the individual points for each source i 34 for(row=0;row<dataSource[i].length;row++) 35 { 36 rows=line[row].split(','); 37 dataGraph[i].push(rows[4]); 38 $('#data').append(i + ' GRAPH DATA ' + dataGraph[i]); 1 $(document).ready(function(){ 2 function testData() 3 { 4 //calls the xml request in a loop based on the current sources 5 var source = ['Mrk 421','Mrk 501']; 6 for (i = 0; i<source.length; i++) { 7 testXMLData(i, source); 39 8 } 40 9 } 41 } 10 11 function testXMLData(index, source) 12 { 13 var testXML; 14 testXML = new XMLHttpRequest(); 15 //NOTE: previous errors on the request was caused by appending "http://www.fact-project.org" 16 testXML.open("GET","/smartfact/index.php?source="+escape(source[index])+"&time="+year+"-"+month+"-"+day,true); 17 dataSource = new Array(); 18 testXML.onload=function() { 19 if (testXML.status==200) 20 { 21 line=testXML.responseText.split('\n'); 22 dataSource.push(line); 23 if (dataSource.length == source.length) 24 displayXMLData(dataSource, source); //this will be called when the last data from the list is read 25 } 26 testXML.send(); 27 } 28 29 function displayXMLData(dataSource, source) 30 { 31 //This function splits the lines of data per data source 32 var dataGraph = new Array(source.length); 33 for (i=0; i<source.length; i++) { 34 dataGraph[i] = new Array(); //dataGraph contains the individual points for each source i 35 for(row=0;row<dataSource[i].length;row++) 36 { 37 rows=line[row].split(','); 38 dataGraph[i].push(rows[4]); 39 $('#data').append(i + ' GRAPH DATA ' + dataGraph[i]); 40 } 41 } 42 } 43 });
Note:
See TracChangeset
for help on using the changeset viewer.