0

I have no html file, I just want my javascript file to understand jquery commands. I tried putting the compressed, production jquery from the jquery site and adding the line

require("./jquery-1.11.0.min");

at the top of my javascript file but I still get an

ReferenceError: $ is not defined

error for my $.ajax() call. What am I doing wrong?

DazedAndConfused
  • 771
  • 3
  • 8
  • 19
  • Are you using the PHP `require` method? That doesn't work the same in JS. Use a script tag to add it to your HTML page. – Hidde Mar 06 '14 at 19:29
  • jQuery does not work in Node.js – SLaks Mar 06 '14 at 19:29
  • 2
    @SLaks — The OP didn't mention Node.js (although it might be implied by the use of `require`, but I was using that in the browser before Node existed). jQuery *does* work in Node anyway, it even has [a package in npm](https://www.npmjs.org/package/jquery). – Quentin Mar 06 '14 at 19:31
  • @Quentin: Standalone jQuery downloaded from their site won't work without a DOM – SLaks Mar 06 '14 at 19:35
  • @Quentin. Thanks, this is exactly what I need. Sorry for the confusing language; this is literally day 2 for me of learning javascript. – DazedAndConfused Mar 06 '14 at 19:36
  • @SLaks — True. Hmm, and "I have no html file" implies that it is probably Node. Although it could still be Rhino or another non-browser based engine. Then again, it could be a browser extension. The question really needs more detail. – Quentin Mar 06 '14 at 19:37

0 Answers0