tornadoweb Access-Control-Allow-Origin jquery POST -
i want enable cors request via jquery using post request handler. below tornado request , jquery
class basehandler(tornado.web.requesthandler): def set_default_headers(self): self.set_header('access-control-allow-origin', '*') self.set_header('access-control-allow-methods', 'post, get, options') self.set_header('access-control-max-age', 1000) #self.set_header('access-control-allow-headers', 'origin, x-csrftoken, content-type, accept') self.set_header('access-control-allow-headers', '*') self.set_header('content-type', 'application/json')
but after calling:
$.ajax({ type: 'post', url: _url, /* beforesend : function(x) { if (x && x.overridemimetype) x.overridemimetype("application/j-son;charset=utf-8"); },*/ beforesend: function ( xhr ) { xhr.setrequestheader('content-type', 'application/json'); xhr.setrequestheader('access-control-request-method', 'post'); xhr.setrequestheader('access-control-request-headers', 'x-requested-with'); xhr.withcredentials = true; }, data : _data, datatype: 'json', contenttype: 'application/json', success: function (data) { alert(data); }, error: function (err) { console.log("ajax response: "+resp+" json="+json.stringify(resp)); } });
and sending:
i receive: reload page source "my post url goes here". ideas catch?
Comments
Post a Comment