1

AJAX 動的作成のために XML ドキュメントを解析する必要があります。ただし、このエラーが発生します。

(document).ready(function(){var departure=$('#departure'); arrival=$('#arrival');
$.ajax({type:"GET", url:"cities.xml", dataType:"xml", success: function(xml)


INFO     2013-02-22 18:16:06,951 dev_appserver.py:3092] "GET /cities.xml HTTP/1.1" 40

ロードするテンプレートと同じディレクトリに 、citys.xmlファイルがあります。

/templates/template_with_jquery
/templates/cities.xml

このエラーが発生する理由を知っている人はいますか?

4

3 に答える 3

1

ローカル URL は、js ファイルが存在するレベルからではなく、トップ レベルに対して相対的です。のようなファイルがないため、404 を取得しているようです<yoursite>/cities.xml

URL を " /templates/cities.xml" に変更すれば問題ありません。

于 2013-02-22T18:35:24.740 に答える
0

これは最初から最後まで技術的な問題でした。ただし、App Engine における yaml ファイルの重要性について、貴重な教訓を得たと言わざるを得ません。変更はapp.yamlファイルで次のようになりました

オリジナル:

1)

url: /static/xml
static_dir: static/xml
upload: static/xml

2)

url: /static/xml
static_files: static/xml
upload: static/xml/cities.xml

正しい&最終:

url:/static/xml
static_dir: static/xml

私が渡していたアップロードの正規表現は、何とも一致しませんでした。とにかく、これは 1 つずつずれているものの 1 つにすぎませんが、100 のエラーのようです。

于 2013-02-24T22:14:42.490 に答える
0

まず第一に、開発サーバーから期待される応答を受け取っていないだけなので、これはおそらく jQuery や XML とは関係ありません。

http://[your-dev-server]/cities.xml にアクセスすると、404 も表示されるので、そこから始めましょう。

city.xml がテンプレートなのか静的ファイルなのかはまだわかりませんが、静的ファイルであると仮定します。

ハンドラー:

url: /updates
static_files: /templates/cities.xml 
upload: /templates/cities.xml

http://[your-dev-server]/updatesサーバーにアクセスすると、/templates/cities.xml

呼び出している URL を取得するには、次のhttp://[your-dev-server]/cities.xmlように変更する必要があります。

url: /cities.xml
static_files: /templates/cities.xml 
upload: /templates/cities.xml

ファイル構造によっては、おそらく最初のスラッシュも削除する必要があります。

url: /cities.xml
static_files: templates/cities.xml 
upload: templates/cities.xml

citys.xml が静的ファイルである場合、テンプレートと静的ファイルを分けておきたいので、実際には templates ディレクトリに置くべきではありません。css、js などの他の静的ファイルと一緒に、cities.xml を静的ディレクトリのどこかに置きます。

url: /static/xml
static_dir: static/xml 
upload: static/xml

これによりstatic/xml/cities.xml、で利用できるようになりますhttp://[your-dev-server]/static/xml/cities.xmlが、でもstatic/xml/countries.xml利用できますhttp://[your-dev-server]/static/xml/countries.xml

citys.xml が静的ファイルでない場合は、さらに情報を提供する必要があります。

于 2013-02-23T10:52:02.763 に答える