Error: Unexpected token "}" was not caught

While debugging my code in Google Chrome, I encountered a red text message:

Uncaught SyntaxError: Unexpected token }.

It's puzzling to me why and where this error is originating. Here is the snippet of code from the source console:

var chart = $('#container1').highcharts();chart.series[0].setData(array2);chart.redraw(); });    //]]>
  • Another Uncaught SyntaxError: Unexpected token }

    </script>
    

This section is written in vb.net:

Dim script As String
    script = _
        "var chart = $('#container1').highcharts();" & _
        '"chart.series[0].setData(array2);" & _
        "chart.redraw();" & _
    " }); "


    ScriptManager.RegisterClientScriptBlock( _
        Me, _
        GetType(Page), _
        "container1", _
        script, _
        True)

An additional Uncaught SyntaxError: Unexpected token } occurred in the vb.net code too.

Answer №1

Consider implementing the following solution:

$(document).ready(function () {

    var chart = $('#plot1').highcharts();

    chart.series[0].setData(updatedArray);

    chart.redraw();
});

Alternatively, you can use this code snippet:

var graph = $('#plot1').highcharts();

graph.series[0].setData(updatedArray);

graph.redraw();

By applying either of these options, you should be able to resolve the error you are encountering.

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

Retrieve the request body in Node.js Express server-side code in order to receive an array passed from the front end

I am facing an issue where I need to save a user's array to mongo. When the data passes through the bridge and reaches the posts, it appears as a strange object with string versions of its indices. I am attempting to convert it back into a normal arra ...

Why does the sub-function not recognize the await keyword in Node.js with asynchronous operations?

As a student learning Node.js, I have been working on a brief example. The GET request on /org is functioning as expected. When attempting to segregate the server "fetch data" logic from the controller by using the GET request on /orgg, I encountered an i ...

Showing the name of a class

Hello everyone, I have a piece of JavaScript code that generates HTML buttons when the page loads. The button attributes are fetched from a database through an ASP page. Everything is working fine except for displaying the class attribute - it shows as u ...

Can I obtain page redirect data using Ajax?

Is there a way to detect URL redirects when making jQuery Ajax requests? For instance, if a request to http://api.example.com is redirected to http://api2.example.com in PHP, can this redirection be captured? Scenario: I am using AJAX to load pages into a ...

Is there a way for me to retrieve a variable from a $.getJSON function?

How can I access the StudentId variable outside of the $.getJSON() function? j.getJSON(url, data, function(result) { var studentId = result.Something; }); //need to use studentId here I suspect this issue is related to scopes and differs from how it ...

Using brush strokes to create a unique design on the canvas page

Currently, I am working on implementing a brush-like effect on a web page. The task involves providing multiple patterns/textures in the background and allowing users to drag their mouse to create the pattern effect on the page. If you want to see the st ...

Using D3.js to generate a set quantity of elements

I am attempting to generate a specific number of elements using D3, extracting this information from a json file. Essentially, if the json data provided is n, I aim to display n elements within my svg. This snippet showcases my code: // Setting up th ...

The module "jquery" in jspm, jQuery, TypeScript does not have a default export

Having some trouble setting up a web app with TypeScript and jspm & system.js for module loading. Progress is slow. After installing jspm and adding jQuery: jspm install jquery And the initial setup: <script src="jspm_packages/system.js"></scri ...

Utilizing a captured group from a regular expression as a key in replacing a string

Looking for help understanding the behavior displayed in this NodeJS 12 console code snippet. I'm attempting to replace a portion of a string with the result from a capture group. While it does work, using that capture group result as a key in an obje ...

Obtain the selected row's ID by leveraging angular.js with either ngSelect or ngOptions

I'm currently working on an angular.js project where I have a dynamic table displaying study results. I want to enhance this by allowing users to view more detailed data about each specific study when they click on the corresponding row in the table. ...

WebView no longer refreshes when the document location is updated

I currently have a basic HTML/JavaScript application (without Phonegap) that I utilize alongside a native Android app and a WebView. When certain situations arise, I need to reload the current page in the JavaScript portion. On my old phone with Android 4 ...

Tips for smoothly applying a class to an image for seamless transitions, avoiding any awkward clunkiness

Check out my work on jsfiddle I understand that the image may not be visible, but I'll do my best to describe it. The header smoothly animates as I scroll down, but the image abruptly changes size instead of smoothly resizing. I want it to gradually ...

In the realm of numeric input in JavaScript (using jQuery), it is interesting to note that the keyCode values for '3' and '#' are identical

I am in need of setting up an <input type="text" /> that will only accept numeric characters, backspace, delete, enter, tabs, and arrows. There are many examples out there, and I started with something similar to this: function isNumericKeyCode (ke ...

Using XML data in Javascript to display map markers on Google Maps

This particular query is related to a previously asked question about Passing XML data to JavaScript in order to display markers on a Google Map. The original question was posed by via8321 and answered by aSeptik on Mar 25 '14. You can find the initi ...

Leveraging an external script for enhanced functionality in React/Meteor application

I'm currently facing a challenge incorporating an external script into my React component within Meteor. I've experimented with directly placing the script tag in my component as follows: TheLounge = React.createClass({ render() { return ( ...

What is the best approach for inserting multiple files into MongoDB with just one JavaScript, Node JS, Shell Script, or mongofile CLI script?

Looking for a way to transfer HTML files from a directory to MongoDB using pure JavaScript, NodeJs, shell script, or mongofile CLI. Any assistance would be greatly appreciated. Thank you in advance. ...

The PHP shopping cart file is returning an undefined JSON response

Currently, I am developing a shopping cart system using a combination of PHP and JavaScript with an xmlhttprequest call to handle the AJAX functionality. The issue I am facing is that whenever the user clicks on the 'add to cart' button, the prod ...

Issues with JSON data not functioning properly when using file system in JavaScript

When attempting to parse a JSON file, I encountered some errors. The file is located in a directory within my JavaScript file, under the 'fs' in a folder named "recipes." Within this folder, there are 3 JSON files, each representing a separate ob ...

Can you explain the purpose of the .json() function in Angular2?

Can you explain the purpose of the .json() function within http requests in Angular2? Here is an example code snippet: this.http.get('http://localhost:8080/getName') .subscribe(res => this.names = res.json()); Is it correct to assume that t ...

Executing Javascript code that has been retrieved using the XMLHttpRequest method in a

Would it be feasible to modify this code to function recursively if the redirects to the js file that needs to be executed? function loadScript(scriptUrl) { var xhr = new XMLHttpRequest(); xhr.open("GET", scriptUrl); xhr.onready ...