JS Bigquery示例在chrome / firefox中工作但在IE中没有?

时间:2014-04-09 05:05:50

标签: google-bigquery

Google开发者提供的以下示例正在使用Chrome / Firfox,但在IE中没有任何问题,我在Windows 8.1中使用IE版本#11(最新版)。

图表没有在IE中显示,而且我得到了一个java脚本错误。![在此输入图像说明] [1]

注意: 1.当我使用Google Developers-JSON示例时,我得到的类似错误...从Bigquery获取记录并在表格中显示...就像在chrome / firefox中执行但在IE中没有? 2.如果可能,请提供和ASP.NET Web应用程序示例,连接google BigQuery并使用C#.NET(不是ASP.NET MVC)在GRIDView中显示数据

  <html>
<head>
<script src="https://apis.google.com/js/client.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
    google.load('visualization', '1', { packages: ['geochart'] });
</script>
<script>
    // UPDATE TO USE YOUR PROJECT ID AND CLIENT ID
    var project_id = 'XXXXXXXXX';
    var client_id = 'XXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com';

    var config = {
        'client_id': client_id,
        //'P12_KEY': 'Keys/ab2c867e84d6d629f0a80595ae14fdbe44492de8 - privatekey.P12',
        //'SERVICE_ACCOUNT' : '87853623787-7lsfbcuu9p3gr9o76opp5fkrvhdf0itk@developer.gserviceaccount.com',
        'scope': 'https://www.googleapis.com/auth/bigquery'
    };

    function runQuery() {
        var request = gapi.client.bigquery.jobs.query({
            'projectId': project_id,
            'timeoutMs': '30000',
            'query': 'SELECT state, AVG(mother_age) AS theav FROM [publicdata:samples.natality] WHERE year=2000 AND ever_born=1 GROUP BY state ORDER BY theav DESC;'
        });
        request.execute(function (response) {
            console.log(response);
            var stateValues = [["State", "Age"]];
            $.each(response.result.rows, function (i, item) {
                var state = item.f[0].v;
                var age = parseFloat(item.f[1].v);
                var stateValue = [state, age];
                stateValues.push(stateValue);
            });
            var data = google.visualization.arrayToDataTable(stateValues);
            var geochart = new google.visualization.GeoChart(
                document.getElementById('map'));
            geochart.draw(data, { width: 556, height: 347, resolution: "provinces", region: "US" });
        });
    }

    function auth() {
        gapi.auth.authorize(config, function () {
            gapi.client.load('bigquery', 'v2', runQuery);
            $('#client_initiated').html('BigQuery client initiated');
        });
        $('#auth_button').hide();
    }
</script>
</head>

<body>
<h2>Average Mother Age at First Birth in 2000</h2>
<button id="auth_button" onclick="auth();">Authorize</button>
<button id="query_button" style="display:none;" onclick="runQuery();">Run Query</button>
<div id="map"></div>
</body>
    </html>    

1 个答案:

答案 0 :(得分:0)

也许是因为你有console.log()语句,而IE并不喜欢这样。