最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Load JavaScript in Google App Engine - Stack Overflow

programmeradmin2浏览0评论

I got so confused loading JavaScript in Google App Engine. I am using the Django template.

First, in my base HTML file, I can't load my downloaded jQuery code from local say, d:/jquery.js, like

<script src="d:\jquery.js" type="text/javascript" ></script></head>,

This line is in my base HTML file. It works when I load jQuery from remote. Like

<script src=".5.1/jquery.min.js"type="text/javascript" ></script></head>

I don't know why.

Second, I can't load my own-created JavaScript code to my HTML file. Say I create a JavaScript file, like layout.js, and I try to load it like this in my child HTML file, which, by the way, inherits from the base HTML.

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

And it doesn't work at all. The only way it works I have tried is when I put the actual JavaScript code in the body of my base HTML file. Like

<body><script>
    $(document).ready(
        $("#yes").click(function() {
            $("#no").hide("slow");
    }));
</script>

I don't know why either... How do I fix it?

I got so confused loading JavaScript in Google App Engine. I am using the Django template.

First, in my base HTML file, I can't load my downloaded jQuery code from local say, d:/jquery.js, like

<script src="d:\jquery.js" type="text/javascript" ></script></head>,

This line is in my base HTML file. It works when I load jQuery from remote. Like

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"type="text/javascript" ></script></head>

I don't know why.

Second, I can't load my own-created JavaScript code to my HTML file. Say I create a JavaScript file, like layout.js, and I try to load it like this in my child HTML file, which, by the way, inherits from the base HTML.

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

And it doesn't work at all. The only way it works I have tried is when I put the actual JavaScript code in the body of my base HTML file. Like

<body><script>
    $(document).ready(
        $("#yes").click(function() {
            $("#no").hide("slow");
    }));
</script>

I don't know why either... How do I fix it?

Share Improve this question edited Aug 25, 2012 at 17:13 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Mar 12, 2011 at 15:53 Clinteney HuiClinteney Hui 4,5655 gold badges25 silver badges23 bronze badges 2
  • Can you word your question more clearly or at least break it up into paragraphs? Also note that ` is the correct character for inserting code rather than * – Patrick Beardmore Commented Mar 12, 2011 at 16:05
  • 4 How could you seriously expect your front-end code to load scripts from your local machine? – Daniel Roseman Commented Mar 12, 2011 at 17:01
Add a comment  | 

1 Answer 1

Reset to default 20

AppEngine doesn't know anything about paths on your local system; it will only upload files that you configure it to. Do this by having a line like this in your app.yaml file:

handlers:
- url: /js
  static_dir: js

In this case, /js represents a subdirectory of your main project directory, and you can put all of your static JavaScript files in there. They will be uploaded to the production server, and you can include them in your HTML with:

<script src="/js/jquery.js" type="text/javascript" ></script>
发布评论

评论列表(0)

  1. 暂无评论