Request explanation - Uncaught ReferenceError message

Richard Rosenheim 86 Reputation points
2023-04-13T00:44:08.78+00:00

I have an ASP.NET MVC (using .NET 4.8 Framework) application. In Visual Studio 2022, when I run the app in debug mode, I get the error message:

Uncaught ReferenceError ReferenceError: $ is not defined
    at <anonymous (localhost:24995/(index):22:36:27:9

I'm assuming that the numbers are (hopefully) line numbers. But in what file?
Presumably the $ refers to jQuery statements, but those numbers don't relate to any lines in the view with jQuery statements. For example, line 22 in the Index view would be the "End Code" statement. Can someone help shine a light on understanding what those numbers mean? Interestingly, all my jQuery appears to work just fine.

Developer technologies ASP.NET Other
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-04-16T19:37:59.51+00:00

    javascript stack trace reports:

    <functionname> <filename> line number:column.

    the format can very by javascript engine. in your case it an anonymous function in the index page html at line 22, column 36. not sure why the second line 29 column 9.

    you would need to view source in the browser of the index page to see the line number.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-04-13T15:41:57.4933333+00:00

    most likely you are running inline jQuery code before jQuery is defined. if you view page source in the browser, you will probably see javascript using jQuery before the jQuery include at the bottom of the file.

    the fix is to be sure script in view is defined in the scripts section.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.