Click here to Skip to main content
15,941,690 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Team

I have javascript libraries and stylesheet on different directories on my local VS IDE. Somehow i am getting this when i debug '
Uncaught syntaxError: Unexpected token Index:60 'function'?
./ Anyone can help me with this error message to fix it.?

What I have tried:

<body>
    <link href="~/Content/vis.css" rel="stylesheet" />
    <link href="~/Content/vis.min.css" rel="stylesheet" />
    <!-- JS -->
    <script src="~/Scripts/gci.min.js"></script>
    <script type="text/javascript">

        function ChartVis(response) {
            var container = document.getElementById('visualization');

            // Create a DataSet (allows two way data-binding)
            var items = new vis.DataSet(response);

            // Configuration for the Timeline
            var options = {};

            // Create a Timeline
            var timeline = new vis.Timeline(container, items, options);
        }
        function OnError(response) {
            alert("Error !");
        }

   
            $(document).ready(function () {
                $.ajax({
                    type: "GET",
                    url: "GetAll",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: ChartVis,
                    error: OnError
            });

    </script>

    <div id="visualization"></div>
Posted
Updated 4-Oct-21 0:53am
v3

1 solution

Placement of your code is very important, if you look at your code you'll notice you've declared your ChartVis and OnError functions inside the $.ajax() method. You need to move those two method declarations somewhere else. You should probably move them above the $(document).ready() line. Similar to:

JavaScript
<script type="text/javascript">

function ChartVis(..) {
  ..
}

function OnError(..) {
  ..
}

$(document).ready(function() {
  ..
});

</script>
 
Share this answer
 
Comments
Tgcobza Mkontwana 4-Oct-21 6:21am    
@Chris Copeland, the issue i have applied that but the vis.js libaries doent want to load the timeline and yet im experience unexpected error. See my update logic from the topic on javascript libraries.
Chris Copeland 4-Oct-21 6:49am    
Your code still isn't correct, you've not closed the $(document).ready() block. If you look at the code you can see that you're missing the }); which would close that function call, and you have a closing } below your script closing tag.
Tgcobza Mkontwana 4-Oct-21 6:55am    
@Chris Copeland, i did made a change but i am still getting the same problem and debug get this error message "Uncaught SyntaxError: Unexpected end of input"
Chris Copeland 4-Oct-21 7:02am    
You still haven't closed the $(document).ready() block correctly. The }); at the end of your script block is closing the $.ajax call, but the parent $(document).ready() still needs to be closed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900