0

I have the following structure:

-uploadpage.html
-index.php
-resources
    -jquery-1.4.2.min.js

On my index.php, I get the contents then output uploadpage.html through this code:

$output = file_get_contents("uploadpage.html");
echo $output;

My upload.html has the javascript at the bottom:

<script type="text/javscript" src="./resources/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
 $(document).ready(
     function() {
      callSomething();
     }
 );
    function callSomething() {return true;}
</script>

However this results in an error "$ is not defined" which means that the jquery js file is not loaded. Any ideas?

2
  • maybe it's just because you aren't defining the external script in the <head> of the site, as it shoud be - or it's because the path is "resources/jquery-1.4.2.min.js", not "./resources/jquery-1.4.2.min.js". PS: why do you mess around with file_get_contents() where you could simply do "include('uploadpage.html')"? Commented Jun 1, 2010 at 14:39
  • I practice placing the javascript just before the ending body tag, as recommended by others (loading the javascript last, css at the beginnig). Path has no issues. I tried using absolute path and same issue happens. This has got to do something with my php code. Commented Jun 1, 2010 at 14:43

2 Answers 2

3

change:

type="text/javscript"

to:

type="text/javascript"
Sign up to request clarification or add additional context in comments.

2 Comments

@mives: Was this another typo in your question?
You know when you have one of those major facepalm moments? I just had it. I did not see that freaking typo on my code. WTF. It is now fixed. D'oh!
1
jquery.1.4.2.min.js
jquery-1.4.2.min.js

If that was just a typo in your question, open up Firebug and look at the "Net" tab to see what the browser is actually trying to load, and what happens when it tries to do that.

1 Comment

Yes, it is only a typo. Under net tab no js is being requested

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.