[SOLVED] Uncaught Reference Error: $ is not defined - SignalR
You are reading this - because you are right place for solution. How to create a very simple singalr chat application step by step will elaborate in another article, with Free source code, you can download.
It is unlikely to get JavaScript, JQuery error during web application development. This is how this article started keeping you in-priority.
I was reading the concepts SignalR implementation, and started to dive into web application project. While implementing a simple chat application in asp.net web application. We developers tend to have error in while develop - errors make us furious and the best warrior, isn't ?
Let's begin here,
1. I created a simple ASP.NET empty web application
2. Added Hub class
3. Added a simple .html page
4. Of-course, before begin the work you must have added Microsoft.AspNet.SignalR
5. Added JavaScript reference
6. Added my own server and client code logic
However - with confidence of above 6 steps, I started to run web application ( Ctrl + F5), the JavaScript error prompted and annoyed downward face.
Error shown : Uncaught Reference Error: $ is not defined
As a developer - what do you think, where I made a mistake in above 6 steps?.
Guess what $ this $ symbol indicates JQuery loading error, you got the point now. The mistake done in Step 5
Route Cause : ~ symbol marked in image caused $ is not defined.
Step by Step
- Firstly, always add the JavaScript library on top
- Add the signalR library second
- Add auto-generated SignalR hub script
Look at the JavaScript references added order in project or web page.
<!--Reference the jQuery library. -->
<script src="../Scripts/jquery-1.6.4.min.js" ></script>
<!--Reference the SignalR library. -->
<script src="../Scripts/jquery.signalR-2.4.1.min.js"></script>
<script src="../Scripts/jquery.signalR-2.4.1.min.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="/signalr/hubs"></script>
SignalR and hubs are auto generated script and "make sure you have same src as above"
ASP.NET Web Application SignalR - View
Summary
SignalR and hubs are auto generated script and "make sure you have same src as above"
ASP.NET Web Application SignalR - View
Summary
As to summarize, JQuery and JavaScript plugins are the most pre-required elements for developers to design application. Thus, solving any error should be a challenge for us to face. I simplify the steps easy and step by step so that everyone who reads have smile on the face that this article serves the best.
0 Comments