Error Encountered with Google Chart in Internet Explorer 8 - CODE70: Access denied format+en,default+en,ui+en,corechart+en.I.js, at line 86, position

Encountering a persistent error when using Google Charts in IE8:

SCRIPT70: Permission denied format+en,default+en,ui+en,corechart+en.I.js, line 86 character 16

The issue arises while working with a parent page where the drawChart() function and global chartDatas array variable are utilized. Upon calling a child page through an ajax request and updating the chartDatas array, calling the drawChart() function triggers the aforementioned error in IE8, particularly when hovering over the page. This continuous error significantly impacts the functionality of the application. The following is a sample code snippet to replicate this problem in IE8 (works fine in modern browsers like Chrome, Firefox, IE10).

parentPage.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE>
<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
            google.load("visualization", "1", {packages: ["corechart"]});
            google.setOnLoadCallback(drawChart);
            var year = 2008;
            var chartDatas = [
                ['Year', 'Sales', 'Expenses'],
                ['2004', 1000, 400],
                ['2005', 1170, 460],
                ['2006', 660, 1120],
                ['2007', 1030, 540]
            ];
            function drawChart() {
                var data = google.visualization.arrayToDataTable(chartDatas);

                var options = {
                    title: 'Company Performance',
                    vAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
                };

                var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
                chart.draw(data, options);
            }
            function callChild() {
                $.ajax({
                    url: "childJsp.jsp",
                    complete: function(res, textStatus) {
                        $('#childPage').html(res.responseText);                        
                    }
                });
            }
        </script>
    </head>
    <body>
        <div id="chart_div" style="width: 900px; height: 500px;"></div>
        <br>
        <input type="button" onclick="callChild();" value="call child page">
        <div id="childPage"> </div>
    </body>
</html>

childJsp.jsp

<script>       
    chartDatas.push([''+(year++), 900, 400]);
    drawChart();
</script>

Upon loading the child page via ajax call, the error is logged in the console.

Answer №1

It appears that a simple adjustment to your code might be beneficial in order to optimize the reuse of the chart object, rather than creating multiple instances unnecessarily.

You may consider implementing the following modification:

Revise your JavaScript as follows:

function drawChart() {
    var data = google.visualization.arrayToDataTable(chartDatas);

    var options = {
        title: 'Company Performance',
        vAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
    };

    var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
    chart.draw(data, options);

    function retrieveChildData() {
        $.ajax({
            url: "childJsp.jsp",
            complete: function(response, status) {
                $('#childPage').html(response.responseText);
                var data = google.visualization.arrayToDataTable(chartDatas);
                chart.draw(data, options);
            }
        });
    }

    var button = document.querySelector('#callChild');
    if (document.addEventListener) {
        el.addEventListener('click', retrieveChildData);
    }
    else {
        el.attachEvent('onclick', retrieveChildData);
    }
}

Remove the retrieveChildData function call from your response. Update the button element in your HTML to this:

<input type="button" id="callChild" value="Retrieve child data">

(You can opt for a different ID as long as it matches with the button element reference in the JavaScript).

To mitigate potential timing issues, you could enhance the output of your childData.jsp page by formatting it into a JSON string like so:

["<year>",<sales>,<expenses>]
. Subsequently, modify the retrieveChildData function within drawChart to:

function retrieveChildData() {
    $.ajax({
        url: "childJsp.jsp",
        dataType: 'json',
        complete: function(response, status) {
            data.addRow(response);
            chart.draw(data, options);
        }
    });
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The HTTP POST function of the controller is failing to trigger when attempting to use the AJAX method

I am trying to create a basic search page where the results are displayed upon clicking the search button. View: @model MvcSearchEngine.Models.SearchResultsModel @{ ViewBag.Title = "Index"; } <script src="~/Scripts/jquery-1.8.2.min.js" type="text/ ...

Insert data into Ajax using a dialog box

I need help with inserting a row into my repair database table from a form that is inside a dialog box and using ajax for the process. Below is the code snippet that triggers the dialog box along with the form: <script> $(function() { ...

"Create a set of arrays within an object that are duplicates four times, and then dynamically manipulate the first item within each array

Here is the layout of my array object: const foo = {"data":[ [1,'asdf'], [2,'lorem'], [3,'impsum'], [4,'test'], [5,'omg'], ]} I am looking to replicate each array four times and increment the first item ...

Executing search bar capability through the use of AJAX and HTTP requests in JavaScript

I am currently working on implementing a search feature that will locate data based on the user's query. Specifically, I want to create a search bar in my HTML that can search for book titles stored in my database accessible through GET requests. Alth ...

Error message in Prestashop console: "jsonData is null, causing a TypeError"

I'm new to Prestashop and running into an issue. Whenever someone clicks the "Add to cart" button, the console displays an error message saying "TypeError: jsonData is null" and the product doesn't seem to get added to the cart. However, upon ref ...

javascript, contrasting functions and variables

As I delve into the world of Javascript and JQuery (hence why I chose the example below), I have observed an interesting behavior. I noticed that not only can I define a function and call it, but I can also just do something else mysterious by using the do ...

Notify the chat when a new record is added to the database

Alright, so here's the issue I'm facing. I created a chat application using PHP and MySQL, but I noticed that when I enter text, it doesn't update in the other window automatically. This led me to experiment with iframes, which I found much ...

What is the proper method for implementing a scrollable effect to the <v-bottom-sheet> element within the Vuetify framework?

Within my Vue.js project, I am utilizing the v-bottom-sheet component from Vuetify framework (version 2.1.12). Upon reviewing my code, you can observe that the v-card is enclosed within the v-bottom-sheet. The issue arises with the scrollable parameter of ...

Is there a problem with the alignment of

<s:form id="inputThresholdForm" name="inputThresholdForm" theme="simple"> <table border="0" class="display-table" cellspacing="2" cellpadding="2" height="100%" width="100%"> <tr> <td colspan= ...

Despite reaching a video readystate of 4 in HTML5, the video still hangs and does not play smoothly

Using html5, I am currently working with video and audio. I have encountered an issue where sometimes the video hangs even after its readyState === 4. The cause of this problem is unclear to me. I aim for a solution where if the video's readyState = ...

The behavior of the select menu is erratic when interacting with AJAX

My dropdown menu is populated dynamically based on AJAX response: function populateDropdown(dropdownNum) { // invokeWebService using $.ajax json = invokeWebService("GET", "/webservice/dropwdownOptions"); optionsHtml = ""; $.each(json, function(count, jsO ...

Is Consistency Possible with CSS Transition Direction?

Take a look at this example: https://codepen.io/jon424/pen/XWzGNLe In the provided code snippet, there is a button that can toggle the visibility of an image. When clicked, the image disappears from bottom to top and reappears when clicked again. The use ...

Guide on pre-selecting an option in a select control using Angular

I need some assistance with the following: My select control is defined as shown below, and I populate its options with strings from an array of strings in my component named tools.Attributes.Serials. Everything is functioning correctly: <select class= ...

Discover the method for retrieving the upcoming song's duration with jplayer

Hey there, I have a question regarding the jPlayer music player. Currently, I am able to retrieve the duration of the current song using the following code snippet: $("#jquery_jplayer_1").data("jPlayer").status.duration; However, I now want to obtain t ...

What is the best way to stringify a JavaScript object that contains a blob as its data?

While recording my webcam using MediaRecoder and sending each blob to the server via Websocket, I encountered a challenge. Initially, I was using the following code: recorder = new MediaRecorder(canvasStream); recorder.ondataavailable = e => ...

What is the best way to incorporate an input id value (based on iteration) into a while loop that points to a specific piece of html located outside of the loop

In my scenario, I need to dynamically add input fields to a form based on the selection made in a dropdown. The issue arises when these new input fields end up sharing the same ID, which is causing problems in the code. To resolve this, I am looking to app ...

Preset for Typescript in Babel 6

Can anyone help me find a Babel preset for Typescript that is compatible with Babel 6, rather than Babel 7? I've been searching for this module with no luck. Is it possible that the TS preset is not supported for Babel 6? ...

Animate a three.js object moving towards the front of the camera

Currently, I have an object that is smoothly tweening towards the front of the camera by using WestLangleys solution from a different question: var pLocal = new THREE.Vector3( 0, 0, -10 ); var pWorld = pLocal.applyMatrix4( camera.matrixWorld ); ...

Tips for efficiently handling multiple form inputs using PHP

As part of my project, I am designing an admin panel for a distribution company. They have specifically requested a feature where they can input orders for all clients through a single page. To meet this requirement, I have created a dynamic form that gene ...

What is the best way to utilize functions from different JavaScript files?

I'm currently handling server-side javascript and I've got confidential data that needs to remain secure, stored in a private directory. If I choose to enclose this data within a function, how can I go about invoking that function from a separate ...