- This topic is empty.
-
AuthorPosts
-
February 3, 2010 at 7:57 am #9710paul-creaseyParticipant
I have a simple jquery click event
<script type="text/javascript"> $(function() { $('#post').click(function() { alert("test"); }); }); </script>
and a jquery reference defined in the site.master
<script src="<%=ResolveUrl("~/Scripts/jquery-1.3.2.js")%>" type="text/javascript"></script>
I have checked that the script is being resolved correctly, I’m able to see the markup and view the script directly in firebug, so I must be being found. However, I am still getting:
$ is not defined
and none of the jquery works. I’ve also tried the various variations of this like
$(document).ready
and jQuery etc.It’s an MVC 2 app on .net 3.5, I’m sure I’m being really dense, everywhere on google says to check the file is referenced correctly, which I have checked and checked again, please advise! :/
February 3, 2010 at 8:00 am #9738tamblerParticipantAre you using any other JavaScript libraries? If so, you will probably need to use jQuery in compatibility mode:
February 3, 2010 at 8:03 am #9731mdm20ParticipantI use Url.Content and never have a problem.
<script src="<%= Url.Content ("~/Scripts/jquery-1.4.1.min.js") %>" type="text/javascript"></script>
August 3, 2010 at 2:28 am #9734alanParticipantI got the same error message when I misspelled the jQuery reference and instead of
type="text/javascript"
I typed “…javascirpt”. 😉January 20, 2012 at 3:32 am #9725ceddParticipantI had this problem once for no apparent reason. It was happenning locally whilst I was running through the aspnet development server. It had been working and I reverted everything to a state where it had previously been working and still it didn’t work. I looked in the chrome debugger and the jquery-1.7.1.min.js had loaded without any problems. It was all very confusing. I still don’t know what the problem was but closing the browser, closing the development server and then trying again sorted it out.
March 14, 2012 at 8:53 am #9712roys_philippinesParticipantWe have the same problem….but accidentally i checked folder properties and set something…
You have to check the properties of each folders that you’re accessing..
- right click folder
- ‘permissions’ tab
- set the folder access :
OWNER: create and delete files
GROUP: access files
OTHERS: access files
I hope that this is the solution……
March 22, 2012 at 4:54 am #9732user1284907ParticipantIn the solution it is mentioned –
“One final thing to check is to make sure that you are not loading any plugins before you load jQuery. Plugins extend the “$” object, so if you load a plugin before loading jQuery core, then you’ll get the error you described.”For avoiding this –
Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery’s case, $ is just an alias for jQuery, so all functionality is available without using $. If we need to use another JavaScript library alongside jQuery, we can return control of $ back to the other library with a call to $.noConflict():
June 3, 2012 at 1:06 am #9726vikrantxParticipantJust place jquery url on the top of your jquery code
like this–
<script src="<%=ResolveUrl("~/Scripts/jquery-1.3.2.js")%>" type="text/javascript"></script> <script type="text/javascript"> $(function() { $('#post').click(function() { alert("test"); }); }); </script>
September 12, 2012 at 8:07 am #9735alexender-dummaParticipantIt sounds like jQuery isn’t loading properly. Which source/version are you using?
Alternatively, it could a be namespace collision, so try using jQuery explicitly instead of using
$
. If that works, you may like to usenoConflict
to ensure the other code that’s using$
doesn’t break.October 23, 2012 at 5:40 am #9727anthonyParticipantI had the same problem and it was because my reference to the jQuery.js was not in the tag. Once I switched that, everything started working.
Anthony
January 18, 2013 at 4:03 am #9713francis-musignacParticipantWhen using jQuery in asp.net, if you are using a master page and you are loading the jquery source file there, make sure you have the header contentplaceholder after all the jquery script references.
I had a problem where any pages that used that master page would return ‘$ is not defined’ simply because the incorrect order was making the client side code run before the jquery object was created. So make sure you have:
<head runat="server"> <script type="text/javascript" src="Scripts/jquery-VERSION#.js"></script> <asp:ContentPlaceHolder id="Header" runat="server"></asp:ContentPlaceHolder> </head>
That way the code will run in order and you will be able to run jQuery code on the child pages.
February 27, 2013 at 5:13 am #9714anthonyParticipantIn my case I was pointing to Google hosted JQuery. It was included properly, but I was on an HTTPS page and calling it via HTTP. Once I fixed the problem (or allowed insecure content), it fired right up.
August 8, 2013 at 12:16 pm #9715springParticipantAfter tried everything here with no result, I solved the problem simply by moving the script src tag from body to head
September 27, 2013 at 8:35 am #9737mimouniParticipantafter some tests i found a fast solution ,
you can add in top of your index page:<script> $=jQuery; </script>
it work very fine 🙂
February 17, 2014 at 11:11 am #9716gavinParticipantI was having this same problem and couldn’t figure out what was causing it. I recently converted my HTML files from Japanese to UTF-8, but I didn’t do anything with the script files. Somehow jquery-1.10.2.min.js became corrupted in this process (I still have no idea how). Replacing jquery-1.10.2.min.js with the original fixed it.
-
AuthorPosts
- You must be logged in to reply to this topic.