Trying to use external json data in sharepoint

150 views
Skip to first unread message

Kevin Regan

unread,
Oct 19, 2012, 6:41:56 AM10/19/12
to google-visua...@googlegroups.com
Hi,

I'm trying to use an external file as an input to a Google Chart in sharepoint. After some research I found a reasonably simple way to do this: https://developers.google.com/chart/interactive/docs/php_example

The example uses an ajax call to a php file to return json file data. 

I saved the php file and sampleData.json file to a location on the sharepoint. The php file simply says:

$string = file_get_contents("https://etc/etc.../Shared%20Documents/scripts/sampleData.json");
echo $string;

In my drawChart function I set the url parameter to the location of the php file as below. However, the chart is not drawn. Am I doing something obviously wrong? I think it may be the url parameter? Any ideas?


    function drawChart() {
      var jsonData = $.ajax({ 
          dataType:"json",
          async: false
          }).responseText;   
   
      // Create our data table out of JSON data loaded from server.
      var data = new google.visualization.DataTable(jsonData);
}

Thanks
K

Kevin Regan

unread,
Oct 19, 2012, 8:18:03 AM10/19/12
to google-visua...@googlegroups.com
I managed to get it working.In the ajax call, instead of referencing the php file I referenced the json file directly. I also included the following script 

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>


it's working now.
Reply all
Reply to author
Forward
0 new messages