-1

I've been searching for the past hour, so I apologize if this is a duplicate I missed.

For some reason the (too long to copy) website I've been working on has recently been giving me JavaScript Console errors like:

Uncaught TypeError: jQuery(...).sidr is not a function Uncaught TypeError: jQuery(...).dataTable is not a function

Notice that I am using jQuery, not $.

Any clue what could be causing this? As I said, my code is WAY too long to copy everything (>1000 lines), plus the issue of removing sensitive/copyright code could be an issue.

Bing
  • 3,071
  • 6
  • 42
  • 81
  • http://stackoverflow.com/questions/6746352/replace-dollar-sign-with-jquery – Said Kholov May 29 '15 at 05:39
  • "*Recently*" – what changed? If you can't reproduce the whole thing, strip everything out of the plugin/function, and add things back until the error is reproduced. Incidentally, without code (and I suspect you anticipated this, given that you twice explain its absence) all we can do is guess. And guessing does very little good. – David Thomas May 29 '15 at 05:39
  • Did you try to replace jQuery by $? – ybdesire May 29 '15 at 05:39
  • @SaidKholov I HAVE been using jQuery, NOT $. You're answering the inverse of my question. – Bing May 29 '15 at 05:42
  • @DavidThomas good advice, but no work has been done here in 6+ months, so the ticket that got entered TODAY is difficult to trace backwards. – Bing May 29 '15 at 05:45
  • @EvanTrimboli How it is not answerable? `What causes this error` seems pretty specific. Would you like 1000 lines of code to parse through, or is there something else useful I can add to the question? Genuinely curious, because I really WOULD like to know what's wrong. – Bing May 29 '15 at 05:48
  • 1
    No, you should do some debugging to put together a test case that demonstrates the issue. That means you spend the time pulling out the relevant parts so it's not 1000 lines, but only the few lines that cause the problem. This will probably lead to you figuring out the issue yourself. – Evan Trimboli May 29 '15 at 05:49
  • Without your code, how could we possibly know "*what causes this error*"? – David Thomas May 29 '15 at 05:50
  • @DavidThomas If someone had *seen* this error before, they might know. I could obfuscate and share 1000 lines, but I don't expect anyone to read that for fun. I think Evan's suggestion of getting a jsfiddle working (if possible) is far more useful. – Bing May 29 '15 at 05:52
  • @Bing if it is a publicly facing website, a URL would likely be the best help. – Robert McKee May 29 '15 at 05:59

3 Answers3

1

Check the javascript loading order. Probably you have your code being loaded before jQuery and it's plugins. Like so:

<script src="yourcode-app-code.js"></script> 
<script src="jQuery.js"></script> 
<script src="jQuery-plugin-sidr.js"></script> 

Your code should be last in the list.

Also check the order of plugins. They should be loaded after jQuery.

Does your code use the jQuery(document).ready() ? If not, then your code is being executeed before jQuery or it's plugins are loaded. So you should change the code so it will execute on page load event.

EDIT

To debug the order you can add console.log right before sidr call in your code and console.log in the start of sidr file and check what's executed first. Just to be sure its not a script loading order issue.

Kremnev Sergey
  • 332
  • 1
  • 8
  • I made that mistake last year. jQuery is literally the FIRST JavaScript file I load. The second is jQuery UI. The third is dataTables. – Bing May 29 '15 at 05:44
0

Well the second error looks like you are trying to use a dataTable, but mistyped it. The first error appears you are trying to use some jQuery add-in that doesn't exist... Did you forget to put a <script src="javascripts/sidr/jquery.sidr.min.js"></script> on your page?

Robert McKee
  • 21,305
  • 1
  • 43
  • 57
  • Negative. sider.min.js is included. Here is sidr, for reference: http://www.berriart.com/sidr/ I AM storing it locally. So maybe I need to update it. But I believe it was working before. – Bing May 29 '15 at 05:43
  • Use the net tab in firebug (or chrome) to make sure that jquery.sidr.js is indeed getting requested and the request is not failing. And make sure jQuery,js is the same (and before jquery.sidr.js). – Robert McKee May 29 '15 at 05:50
0

Check if you're loading jQuery twice by accident, some code might then call jQuery.noConflict() which might replace your expected jQuery with an other version.

You might check for jQuery.fn.jquery, maybe even the jQuery version differs to your expected one.

Damian Senn
  • 1,135
  • 1
  • 9
  • 13