开发者

tornado server not returning response with self.write

开发者 https://www.devze.com 2023-01-09 06:22 出处:网络
I have a simple tornado server running like this: import json import suds from suds.client import Client

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) i开发者_如何转开发s blank. Even firebug shows a blank response (the http status is 200 though). Anybody have a clue??


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消