Hallo,
also Port 8080 ist der Port, da greife ich auch mit dem Firefox drauf zu, Firebug zeigt mir da keine Fehler an.
Das hier
Remember that for security reasons (that is preventing cross-site scripting attacks) Ajax requests can only be made to URLs of the same protocol, host and port of the page containing the Ajax request. Some browsers might allow arbitrary URLs, but you shouldn't rely on support for this.
hab ich aber bisher nicht beachtet. Also werd ich die Seite erstmal in Python einbinden und gucken ob es dann was macht.
Danke für die Hilfe
Ich hoffe nur das funktioniert dann auch endlich.
Update:
ooook, jetzt hab ich meine xhtml Datei mal in den Cherrypy Code eingebunden:
Code: Alles auswählen
import cherrypy
class HomePage:
@cherrypy.expose
def index(self):
return file("test.xhtml")
class Test2:
@cherrypy.expose
def index(self):
return 'test2'
def test3(self):
return 'test3'
root = HomePage()
root.test = Test2()
cherrypy.tree.mount(root)
if __name__ == '__main__':
import os.path
cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'side.conf'))
cherrypy.server.quickstart()
cherrypy.engine.start()
tools.trailing_slash.on = False
und bekomme folgende Fehler von Firebug:
test is not defined
onload(load )
[Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: file:///C:/PROGRA~1/MOZILL~1/components/nsSessionStore.js :: sss_saveState :: line 1753" data: no]
[Break on this error] oState.session = { state: ((this._loadState == STATE_RUNNING) ? STATE_RUNNIN...
Also den ersten Fehler verstehe ich ja noch, da ärgert mich jetzt Cherrypy indem es mir folgendes anstelle des Javascript codes einbindet:
Code: Alles auswählen
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html>
3<head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
5 <title>404 Not Found</title>
6 <style type="text/css">
7 #powered_by {
8 margin-top: 20px;
9 border-top: 2px solid black;
10 font-style: italic;
11 }
12
13 #traceback {
14 color: red;
15 }
16 </style>
17</head>
18 <body>
19 <h2>404 Not Found</h2>
20 <p>The path '/test.js' was not found.</p>
21 <pre id="traceback">Traceback (most recent call last):
22 File "c:\python25\lib\site-packages\cherrypy\_cprequest.py", line 551, in respond
23 cherrypy.response.body = self.handler()
24 File "c:\python25\lib\site-packages\cherrypy\_cperror.py", line 198, in __call__
25 raise self
26NotFound: (404, "The path '/test.js' was not found.")
27</pre>
28 <div id="powered_by">
29 <span>Powered by <a href="http://www.cherrypy.org">CherryPy 3.0.3</a></span>
30 </div>
31 </body>
32</html>
Die zweite Fehlermeldung kommt wahrscheinlich wegen genau dem selben Problem mit der Prototype.js Datei.
Jetzt währe also erstmal meine Frage: Wie binde ich die Javascript Dateien ein, so das Cherrypy sie auch kennt? (Alle Dateien liegen im selben Verzeichnis ohne unterverzeichnisse)
Update2:
Da habe ich jetzt zu vorschnell gefragt.
Code: Alles auswählen
import cherrypy
class HomePage:
@cherrypy.expose
def index(self):
return file("test.xhtml")
@cherrypy.expose
def prototype(self):
return file("prototype-1.6.0.2.js")
@cherrypy.expose
def testjs(self):
return file("test.js")
class Test2:
@cherrypy.expose
def index(self):
return 'test2'
def test3(self):
return 'test3'
root = HomePage()
root.test = Test2()
cherrypy.tree.mount(root)
if __name__ == '__main__':
import os.path
cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'side.conf'))
cherrypy.server.quickstart()
cherrypy.engine.start()
tools.trailing_slash.on = False
Und Javascript so einbinden:
Code: Alles auswählen
<script src="http://localhost:8080/prototype" type="text/javascript"></script>
<script src="http://localhost:8080/testjs" type="text/javascript"></script>
So funktioniert jetzt alles und danke nochmal für die Hilfe und die Ratschläge!