1

I was trying to call a function from a .js file in the Google App Engine enviroment.

the code of the html print goes like this:

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class jumpPage(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write('');
        self.response.out.write('');
        self.response.out.write('<head>');
        self.response.out.write('<script type="text/javascript" src="/js/pxc11.js" >');
        self.response.out.write('</script>');
        self.response.out.write('</head>');
        self.response.out.write('<body">');
        self.response.out.write('<form name="f1">');
        self.response.out.write('  <input type="hidden" name="theStartValue" value="1"><p>');
        self.response.out.write('  <input type="button" value="-15" onClick="dummy()">');
        self.response.out.write('  <input type="button" value="+15" onClick="dummy()" ><p>');
        self.response.out.write('</form>');
        self.response.out.write('</body>');
        self.response.out.write('');
        self.response.out.write('</html>');


application = webapp.WSGIApplication(
                                     [('/tonteria', jumpPage)],
                                     debug=True)


def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

and then the .js is just this:

<script language="javascript" type="text⁄javascript">
function dummy()
{
    alert("POPOPOPOPOPO");
}
<⁄script>

The app.yaml includes a static folder that has the .js file.

    handlers:
    - url: /js
      static_dir: js
    - url: /tonteria
      script: tonteria.py
3
  • 1
    Yes, and what happens? Be specific. Commented Dec 5, 2011 at 18:26
  • I'm sorry, what happened was that the HTML was showing and I could see and click the buttons but the Javascript functions weren't triggered. I was putting these HTML tags in the .js code... Commented Dec 5, 2011 at 18:37
  • You'll save yourself a lot of editing headache by using templates. Commented Dec 5, 2011 at 18:57

2 Answers 2

4

.js files contain Javascript, not HTML tags.

Sign up to request clarification or add additional context in comments.

1 Comment

mmmm omg maybe that's the error, feel kind of ridiculous! Ok it works now, thanks a lot!
0

Your life might be easier by making the file into an html template and then rendering it with your variables. Google has a great tutorial

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.