PHP Ferrari
PHP Ferrari

Reputation: 15616

$ is not defined

I'm having an issue on a site I'm building where the datatable is not loading (on server) but works fine on local host (xamp). Firefox throws an error, "$ is not defined."

I've googled the errors, and I found a friend's solution that jquery.js file has not been included or your reference to it is pointing to the wrong location.

But I checked the file path twice & thrice and it is correct & the jquery.js is also there.

Any help is appreciated,

Upvotes: 1

Views: 1572

Answers (3)

Daniel Rikowski
Daniel Rikowski

Reputation: 72514

It is possible that the $ object is used before jquery.js is imported.

A typical cause of this would be using some kind of jQuery plugin:

If you have this:

<script src="jquery.someplugin.js">
<script src="jquery.js">

try changing it to this:

<script src="jquery.js">
<script src="jquery.someplugin.js">

To be sure: Use Firefox with Firebug plugin and look where exactly the problem occured. Then you can be sure.

Upvotes: 5

Residuum
Residuum

Reputation: 12064

It looks like juery.js is not readable. Have you tried accessing jquery.js directly from your browser? If you get a access denied error, chmod the file to 644 (rw-r--r--).

Upvotes: 1

Romain Linsolas
Romain Linsolas

Reputation: 81617

If jQuery is correctly included in your page, maybe another library (such as prototype) is also present. Thus, to avoid conflict, jQuery provides another a noConflict() function. In this case, the $ is replaced by jQuery.

So instead of doing something like $("some selector").doSomething(); you will have to do jQuery("some selector").doSomething();

Upvotes: 5

Related Questions