2013-10-27 43 views
0

在我的PHP應用程序,我有一個jQuery,但它不運行,其他部分做得很好,而且我確定它在我的主機運行良好。它就像這樣在我的html:<script src="jquery.min.js"></script> 所以我猜我的app.yaml有問題。jquery不運行在PHP應用程序

以下是我的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 

我是一個biginner,所以也許它只是一個小問題。但是我爲它工作了好幾天,仍然找不到方法。請幫助我。這是我的網站:https://nicol06215.appspot.com/index.html它應該顯示窗口,當你點擊列。

+1

你在控制檯中看到了什麼? – SLaks

+0

它可以在控制檯中使用。 – user2924206

回答

0

在YAML的第一行是:

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

所以,如果你要求yoursite.com/jquery.min.js前行匹配網址和要求應該尋找照片jquery.min.js。

不應該需要第二個和第三個處理程序。

那麼它看起來像你

- url: /(.+) 

做一遍這樣的一個處理(最後一個)是由這個問題,以及處理,不需要/使用該匹配的一切。

如果您要求yoursite/jquery.min.js您是否收到未找到錯誤?

我認爲,如果你想的index.html當用戶請求,你可以做以下的根使用:

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

此刻你的下一個和prev.png都沒有上傳,但也有沒有腳本錯誤。你使用的是jQuery的一個漂亮的舊版本,但如果它適合你,那很好。

+0

謝謝,我按照你的說法改變它,https://nicol06215.appspot.com/jquery.min.js沒有問題,但我仍然無法修復我的網站。還有一件事是我必須輸入/index.html,它對我來說是揮之不去的。 https://nicol06215.appspot.com/index.html – user2924206

+0

@ user2924206更新了我的答案。 – HMR

+0

是的,我認爲你是對的,關鍵是舊版本,我會嘗試一些新的,非常感謝。 – user2924206

0

你已經得到了你的答案,但你可能想知道我如何鏈接到jQuery並在我的GAE應用程序中使用它。

我製作了2個文件夾stylesscripts,並將我的腳本和樣式文件放入其中。然後在我的HTML「頭」標籤鏈接到他們就像一個正常的網站:

<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 

這樣我不需要爲每個文件名稱請求指定一個處理程序。我只是說任何以「樣式」或「腳本」開頭的請求(例如:- url: /scripts),請使用樣式或腳本文件夾/目錄(例如:static_dir: scripts)來處理它。

+0

是的,它更好,謝謝 – user2924206

+0

你也可以鏈接到CDN,比如''所以你不必在你的YAML中指定它。 –