views:

84

answers:

1

Hi, I have a simple tornado server running like this:

import json
import suds
from suds.client import Client
import tornado.httpserver
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):

    def get(self):
        url = "http://xx.xxx.xx.xxx/Service.asmx?WSDL"
        client = Client(url)
        resultCount = client.service.MyMethod()
        self.write(json.dumps({'result_count':resultCount})) 

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(6969)
    tornado.ioloop.IOLoop.instance().start()

Now, I have a jquery function that calls this tornado code like this:

 $.get("http://localhost:6969",
            function(data){
                alert(data);
                $('#article-counter').empty().append(data).show();
            });

For the life of me, I don't understand why data (the response) is blank. Even firebug shows a blank response (the http status is 200 though). Anybody have a clue??

+2  A: 

I finally figured out what was wrong: my app wasn't following the 'same domain origin' policy. So when the ajax request was being sent, the referrer header was from a different port than my tornado server. Naturally the server didn't return a response!

PythonUser