swoosh
swoosh

Reputation: 657

loading external javascripts with GAE

I'm having some trouble loading external javascripts using google app engine. I basically have an index.html file with the following on the header section:

<script type="text/javascript" src="/jsfunctions.js"></script>

and the following in the body section:

<p id="demo"></p>
<button  type="button" onclick = DisplayDate() >Display Date</button>

In the jsfunctions.js file, I have:

function DisplayDate(){
    document.getElementById("demo").innerHTML=Date();
}

When I run this, I can see that the page gets the jsfunctions.js:

INFO 2012-05-06 00:37:25,864 dev_appserver.py:2884] "GET /jsfunctions.js HTTP/1.1" 404 

However, nothing happens when I click on the button.

Am I missing something important here?

Upvotes: 0

Views: 611

Answers (2)

Dave W. Smith
Dave W. Smith

Reputation: 24966

Unless you declare a static_files entry for jsfunctions.js (or put it in a subdirectory that you declare with static_dir), your handler has to be prepared to serve it.

See https://developers.google.com/appengine/docs/python/config/appconfig#Static_Directory_Handlers

Upvotes: 1

gcochard
gcochard

Reputation: 11734

The transfer log entry says 404, that means your js file was not loaded. Double check that it is being served when you enter the URL to the file.

Upvotes: 0

Related Questions