jquery不在php应用程序中运行

时间:2013-10-27 02:07:40

标签: javascript php google-app-engine

在我的php应用程序中,我有一个jquery,但它没有运行,其他部分运行良好,我确信它在我的主机中运行良好。在我的html中就像这样:<script src="jquery.min.js"></script> 所以我觉得我的app.yaml出了问题。

以下是我的app.yaml:

application: *
version: 1
runtime: php
api_version: 1
handlers:
- url: /(.*\.(htm$|html$|css$|js$))
  static_files: photo/\1
  upload: photo/(.*\.(htm$|html$|css$|js$))

- url: /jquery.min.js
  static_files: photo/\1
  upload: photo/jquery.min.js

- url: /index.html
  static_files: photo/\1
  upload: photo/index.html  

- url: /albums/(.*\.(ico$|jpg$|png$|gif$|swf$))
  static_files: photo/albums/\1
  upload: photo/albums/(.*\.(ico$|jpg$|png$|gif$|swf$))


- url: /(.+)
  script: photo/\1
  secure: always

- url: /photostack.php
  script: photo/photostack.php
  secure: always

我是一个大人物,所以也许这只是一个小问题。但我工作了好几天,仍然找不到方法。请帮助我。这是我的网站:https://nicol06215.appspot.com/index.html它应该在您点击列时显​​示窗口。

2 个答案:

答案 0 :(得分:0)

你的yaml的第一行是:

url: /(.*\.(htm$|html$|css$|js$))

因此,如果您请求yoursite.com/jquery.min.js,则前一行与该网址匹配,请求应在照片中查找jquery.min.js.

不应该需要第二个和第三个处理程序。

然后看起来你再次在

中再做一遍
- url: /(.+)

这匹配所有内容,因此下一个处理程序(最后一个)也由此处理,不需要/使用。

如果您请求yoursite/jquery.min.js,您会收到未找到的错误吗?

我认为如果您希望在用户请求root用户时使用index.html,则可以执行以下操作:

handlers:
- url: /
  static_files: photo/index.html

目前您的next和prev.png没有上传,但没有脚本错误。你正在使用一个非常古老的jQuery版本,但如果它适合你,那就没关系。

答案 1 :(得分:0)

您已经得到了答案,但您可能想知道我如何链接到jQuery并在我的GAE应用程序中使用它。

我制作了2个文件夹stylesscripts,并将我的脚本和样式文件放入其中。然后在我的HTML“head”标签中链接到它们就像一个普通的网站:

<link rel="stylesheet" type="text/css" href="styles/list.css" />
<script src="scripts/jquery.min.js"></script>

然后在我的yaml文件中,我将它们定义为:

- url: /scripts
  static_dir: scripts

- url: /styles
  static_dir: styles

通过这种方式,我不需要为每个文件名请求指定一个处理程序。我只是说任何以“styles”或“scripts”开头的请求(例如:- url: /scripts),使用样式或脚本文件夹/目录(例如:static_dir: scripts)来处理它。