Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6064257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:15:38+00:00 2026-05-23T09:15:38+00:00

Hi I have the following script The page can also be seen in action

  • 0

Hi I have the following script

The page can also be seen in action here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<!-- Version: 1.0.0 -->
 <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Flot Examples</title>
    <link href="layout.css" rel="stylesheet" type="text/css">
    <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
    <script language="javascript" type="text/javascript" src="../jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
 </head>
   <body onLoad="myFunction()">


            <a href="javascript:printing()">Show All Coverafdedge</a>
            Show: </div>        

    <p><span id="x">0</span>, <span id="y">0</span></p>


      <p><input id="enableTooltip" type="checkbox">Enable tooltip</p>



<script type="text/javascript">

var datasets = [];

var xmlhttp;
function loadXMLDoc(url,cfunc){
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=cfunc;
    xmlhttp.open("GET",url,true);
    xmlhttp.send();
}


function myFunction(){

    loadXMLDoc("parsers.json",handleXML);
}
var checkState = function(xmlhttp, callback) {
//document.write(xmlhttp.readyState);
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    callback();
  } else {
    // Check back again 1 sec later
    setTimeout(checkState, 1000);
  }
};

function handleXML() {
checkState(xmlhttp, function() {

    var txt=xmlhttp.responseText;
    datasets = [];
    var datasetsCounter =0;
    var secondPos = 0;
    var aPosition = 0;
    var currentCharacterLocation =0;
    var textLeft =txt;
do
  { 
    aPosition = textLeft.indexOf("#");
    secondPos = textLeft.indexOf(";");
    evaluedText = textLeft.substring(aPosition+1,secondPos);
    datasets[currentCharacterLocation] = eval("(" + evaluedText + ")");
    currentCharacterLocation++;
    textLeft = textLeft.substring(secondPos + 1);
  }
while (textLeft.indexOf("#") > -1);


 }); 
} 


function printing(){
for(var g =0; g < datasets.length; g++ ){
document.write(datasets[g].cover.data + "__");
}
}

$(function () {
    var d1 = [];
    var d2 = datasets[0].cover.data;
    // a null signifies separate line segments
    var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];

    $.plot($("#placeholder"), [ d1, d2, d3 ]);
});

</script>       
</body>     
</html>

Now to my problem that I have with the variable “datasets”, if I for example try to print out “datasets[0].cover.data” (Like I do in my function printing(), I can do that (Try yourself clicking on the link on that page). But when I try to use the variable inside the

“var d2 = datasets[0].cover.data”, I get the error that its datasets[0].cover.data is not defined :S

Anyone know what I am doing wrong here? =)

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:15:39+00:00Added an answer on May 23, 2026 at 9:15 am

    Your issue is that the function in $(function() { … }); is running when your body onload is called. You need to do something like

    $(function () {
        loadXMLDoc("parsers.json", function () {
            handleXML(); // possibly add a callback to this function which calls the remaining code in this function
    
            var d1 = [];
            var d2 = datasets[0].cover.data;
            // a null signifies separate line segments
            var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
    
            $.plot($("#placeholder"), [d1, d2, d3]);
        });
    });
    

    And then remove the call from body onload

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following page: <html> <head> <title>Test</title> <script type=text/javascript> function BuildTree() { var
I have the following code on an html page: <script type=text/javascript> <!-- window.location.replace(http://www.example.com/); -->
I have the following script which appears multiple times on my page. I have
I have the following Javascript libraries loaded for my page. <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js></script> <script
I have made the following search script but can only search one table column
I have the following code on my Home.aspx page: <form id=frmJump method=post action=Views/ViewsHome.aspx> <input
I have the following script in my web page to call out to a
I have following small script to preview some text before submitting it to store
I have the following script which first shows only the first para of the
I have the following script: Timer=0; function countdown(auctionid){ var auctions; var divs; Timer=Timer+1; if((Timer%10==0)||(Timer==1)){

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.