0

I have a working HTML file with some javascript in it. I use NodeJS to send it to the client using fs.readFile() and response.write(). The problem with this is that, although the HTML renders fine, the javascript (which includes jQuery) doesn't load.

4
  • 1
    Don't say "loading jQuery with NodeJS". NodeJS shouldn't load it, the browser should. Commented Aug 7, 2011 at 10:06
  • 1
    uh, are you ending your response? response.end(). Try using a framework. I like connect, but express is easier. These have static file handlers. Commented Aug 7, 2011 at 10:08
  • 1
    Code... post your source code where you are doing this magic. Commented Aug 7, 2011 at 10:11
  • Probably because you only have one case for the fsreadFile(), mainly for your html. You must also tell it that when you request something called jquery.js (or w/e), to read that specific file and send it back. But better to using something like express framework! Commented Aug 8, 2011 at 16:40

1 Answer 1

1

You really shouldn't manually do "fs.readFile()" and "response.write()". Have a look at "lightnode" for serving static files: https://github.com/ngspinners/lightnode

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.