Edi 0
Edi 0

Reputation: 212

HighChart not working when called by ajax

Hi guys i have a page which is working perfectly it contains a highchart. I want to show this page on the existing page through an ajax call. My ajax is working perfectly but the highcharts are not displaying when i make ajax call.

link of my highchart is

http://www.rahatcottage.com/AI/J/examples/line-log-axis/index.php

And My ajax script goes here

var xmlhtt

 function load(str,str1)
    {


      xmlhtt=GetXmlHttpObject();

     if (xmlhtt==null)
     {
       alert ("Your browser does not support Ajax HTTP");
       return;
       }

        var url="examples/line-log-axis/index.php";
         url=url+"?q="+str;
         url=url+"&q1="+str1;

       xmlhtt.onreadystatechange=getOutpt;
      xmlhtt.open("GET",url,true);
      xmlhtt.send(null);
       }

        function getOutpt()
         {

         if                                     (xmlhtt.readyState==3||xmlhtt.readyState==2||xmlhtt.readyState==1|
       |xmlhtt.readyState==0)

{

         document.getElementById("apDiv1").innerHTML="Loading ";

}

     if (xmlhtt.readyState==4)
      {
      document.getElementById("apDiv1").innerHTML=xmlhtt.responseText;
          document.getElementById("apDiv1").focus();
          }
            }

            function GetXmlHttpObject()
               {
    if (window.XMLHttpRequest)
         {
   return new XMLHttpRequest();
        }
       if (window.ActiveXObject)
       {
  return new ActiveXObject("Microsoft.XMLHTTP");
         }
       return null;
           }

I guess because highgraphs are using Jquery thats y ajax is not running them

Upvotes: 0

Views: 800

Answers (1)

Jugal Thakkar
Jugal Thakkar

Reputation: 13482

EDITED So what you are doing is, that you have a working chart page, and through ajax you wish to load that page into a div of another page. I don't think that will be possible, you can just do that, especially if that page has javascripts, what you are doing is just getting the generated html of the working chart page, and pasting it inside the div, this won't run the necessary javascripts for the chart generation.

Try using an iframe instead.

HTML

<iframe id="frame" />

SCRIPT

function load(str,str1)
{
     $('#frame').attr('src', "examples/line-log-axis/index.php?q="+str+"&q1="+str1);
}
**OLD** series: [{ data: JSON.parse("[" + text + "]") }] `text = ','`, hence a json parse error. Revisit your json building @ php to correctly spit `text`

Upvotes: 1

Related Questions