5

This is the Python script I have running on Google App Engine:

import webapp2

form = """
<form action="/testform">
  <input name="q">
  <input type="submit">
</form>
"""

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers.add_header("Access-Control-Allow-Origin", "*")
        self.response.write(form)

class TestHandler(webapp2.RequestHandler):
  def get(self):
    q = self.request.get("q")
    self.response.out.write(q)
    print(q)

app = webapp2.WSGIApplication([
    ('/', MainPage),
    ('/testform', TestHandler)], 
    debug=True)

I'm running an AJAX on the console to see if I can get the two to talk to each other.

$.ajax({
  type: 'GET',
  url: url,
})

However, I'm getting an error:

jquery.min.js:4 GET https://localhost:8080/testform?q=somethingnew1 net::ERR_SSL_PROTOCOL_ERROR

I tried Googling it, but not sure what it means. Could anyone give some advice on what I'm doing wrong, and how I should go about fixing it?

Thanks!

Morgan Allen
  • 3,291
  • 8
  • 62
  • 86
  • 2
    I am pretty sure that the webserver running on your `localhost:8080` is not configured to work with SSL, thus you need to fix your URL - use `http://` instead of `https://`. – Jozef Chocholacek Jul 28 '16 at 13:43
  • 1
    When I use `http://` I get this error: `jquery.min.js:4 Mixed Content: The page at 'https://cloud.google.com/appengine/docs/python/gettingstartedpython27/deploying-the-application' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost:8080/testform?q=somethingnew1'. This request has been blocked; the content must be served over HTTPS.` – Morgan Allen Jul 28 '16 at 14:04
  • Hm, and are you really sure you need to call **localhost** then? If yes, then according to http://stackoverflow.com/questions/4032104/http-ajax-request-via-https-page you have to configure your local webserver to run over SSL. – Jozef Chocholacek Jul 28 '16 at 14:08
  • If I didn't call `localhost:8080` would would I make the url be? – Morgan Allen Jul 28 '16 at 14:10
  • What should your AJAX do? Should it call that Python script? Then you need to use `https://cloud.google.com/...`. Anyway, I kind of not understand what you are trying to achieve. – Jozef Chocholacek Jul 28 '16 at 14:20

0 Answers0