frankie
Members-
Content count
2 -
Joined
-
Last visited
Everything posted by frankie
-
FusionChart live data updates in firefox but not Internet Explorer
frankie posted a topic in Javascript Problems
I have been having this issue that has been driving me crazy. I am using a php script to run a query on a database and take the information and put it into a XML file. I then have some AJAX code where it calls the php file so that it updates the xml file, and then it renders the graph, and it does this every minute so there is live data, but the problem is, in firefox the graph gets updated with live data no problem, but in Internet explorer, I need to shut it down and open it back up to the page to get live data, and no matter how many refreshes I do, it will still stick to the same data. Here are my codes AJAX code: function refreshdiv_chart(){ var seconds = 60; var divid = "graphDiv"; var url = "phpModules/incidentgraph.php"; var xmlHttp; try{ xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari } catch (e){ try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer } catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("Your browser does not support AJAX."); return false; } } } var timestamp = fetch_unix_timestamp(); var nocacheurl = url+"?t="+timestamp; xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4){ var myChart = new FusionCharts("FusionCharts/Column3D.swf", "myChartId", "1200", "450", "0", "0"); myChart.setDataURL('phpModules/dataxml.xml'); myChart.render("graphDiv"); setTimeout('refreshdiv_chart()',seconds*1000); // Runs this function every minute for live data } } xmlHttp.open("GET",nocacheurl,true); //runs php script to update XML FILE xmlHttp.send(null); } Here is my PHP file - incidentgraph.php <?php /* create file called dataxml so that graph can take information from it, and information is not appended, whenever query is ran the new infromation overwrites the file */ $fp = fopen('dataxml.xml', 'w'); /* Connect to production server */ $serverName = "hostname.servername"; $uid = "username"; $pwd = "password"; $connectionInfo = array( "Database"=>"information","UID"=>$uid,"PWD"=>$pwd); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn === false ) { echo "Could not connect."; die( print_r( sqlsrv_errors(), true)); } //$strXML will be used to store the entire XML document generated //Generate the chart element Please see fusioncharts documentation $strXML= ""; //Fetch all factory records $tsql = "SELECT COUNT([Login ID BY]), [Login ID BY] FROM [sDE].[_SMDBA_].[incident] WHERE DATEDIFF(DAY,[Open Date & Time], GETDATE())=0 AND [Opened Group:]='HD' GROUP BY [Login ID BY] ORDER BY [Login ID BY] ASC "; /* Execute the query. */ $stmt = sqlsrv_query( $conn, $tsql); if ( !$stmt ) { echo "Error in statement execution."; die( print_r( sqlsrv_errors(), true)); } //Iterate through each factory while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) { $strXML .= ""; } sqlsrv_free_stmt( $stmt); sqlsrv_close($conn); //Finally, close element $strXML .= ""; /* take all of the xml info and write it to the file */ fwrite($fp, "$strXML"); fclose($fp); ?> -
FusionChart live data updates in firefox but not Internet Explorer
frankie replied to FusionCharts Support's topic in Javascript Problems
Thanks sooo much, it works great!!!!!!!!!!!!!!